Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!stiatl!srchtec!johnb From: johnb@srchtec.UUCP (John T. Baldwin) Newsgroups: comp.lang.c Subject: Re: C preprocessing Message-ID: <223@srchtec.UUCP> Date: 24 Sep 90 14:55:25 GMT References: <59770@iuvax.cs.indiana.edu> Organization: search technology, inc. Lines: 65 [ellipsis indicates deletion for brevity --jtb] In article <59770@iuvax.cs.indiana.edu> bomgard@iuvax.cs.indiana.edu (Tim Bomgardner) writes: >Wouldn't it be nice ... if the compiler would do what I meant >instead of what I said? >... >Code is written two-dimensionally ... why does it have to processed as > a one-dimensional string of tokens? >... > if (bool_expression) > do_something(); > do_something_else(); > if (another_bool_expression) > do_anything(); > else > do_this_when_bool_expression_is_false(); This begs several questions. #1 Why does the program have to be processed as a one-dimensional string of tokens? It doesn't. At least, programs in general do not have to be processed this way. Your C programs are, because the language has been defined that way. The reason why language designers like to do this is because it makes it easier to write the compiler (i.e. the lexer and parser are easier). If this is not complete enough for you, I'd suggest learning something about compilers. I'm *not* a compiler expert, but a good book to read is the so-called "Dragon Book" by Aho, Sethi, and Ullman (sp?). At least it is a widely-known text, and I liked it. :-) #2 Why can't the compiler "catch" the fact that what was meant (above) isn't what was said? Because a compiler's job is to translate what was *said*. The only analysis the compiler is required to perform is whatever is germane to that task. If you want a critique, use LINT or a lint-like analyser. At least one LINT that I know of "understands" general indentation rules and will flag the probable error above, i.e. "line xxx: do you know you *outdented* the 'else' that goes with 'if (another_bool_expression)' ???" #3 Wouldn't it be nice if the compiler would do what I meant, instead of what I said? Yes. When you (or anyone else) manages to do this, be *sure* to publish. Quickly. You'll probably win a Nobel Prize. :-) :-) :-) :-) :-) -- John T. Baldwin | johnb%srchtec.uucp@mathcs.emory.edu Search Technology, Inc. | | "... I had an infinite loop, My opinions; not my employers'. | but it was only for a little while..."