C preprocessing

Bruce R. Miller miller at GEM.cam.nist.gov
Fri Sep 28 03:42:15 AEST 1990


In article <151583 at felix.UUCP>, Alvin E. Sylvain writes: 
> In article <18102 at haddock.ima.isc.com> karl at kelp.ima.isc.com (Karl Heuer) writes:
>>In article <59770 at iuvax.cs.indiana.edu> bomgard at iuvax.cs.indiana.edu (Tim Bomgardner) writes:
>>>Wouldn't it be nice, if ... the compiler would do what I meant [by
>>>interpreting the indentation] instead of what I said?
>>
>>I personally like the idea, but it's not C (nor any other language I use,
>>though I understand Occam has it).  So, being realistic, let's say instead:
>>Wouldn't it be nice if the compiler (or some related tool) would provide
>>(optional!) warnings for possibly misindented code?
>> ...
> Just write a PRE-pre-processor.  ...

At the risk of being flamed from multiple directions [ 1)I'm from the Lisp
camp, 2) I'm from the Emacs camp and 3) There's currently a debate on
comp.lang.lisp on the `virtues (or lack thereof) of lisp syntax'] 

`Good' editors like Emacs have a lisp mode which does a variety of
helpful things for you:

  1) TAB moves you to the appropriate indentation according to the
nesting level where you are typing. [the amount of indentation each kind
of form gets is often customizable. Also there is often single stroke
`newline and tab' command.  If the cursor moves to an odd place you've
got an immediate clue that you've messed up the nesting.
  2) Depending on the capabilities of the console/terminal, the
balancing parenthesis (open or close) will be blinked when the cursor is
on a parenthesis. [On some terminals, perhaps only when you type the
paren.]
  3) There is a command to re-indent a whole expression or definition.
     (c-m-Q)
  4) By typing the comment start character the cursor is moved to an
appropriate (customizable) position to start the comment.
  5) Saving a file will check for balancing parenthesis first.
 ...and so on...

Now granted, not all of this has an exact correspondence in C, and Lisp's
uniform syntax makes it particularly simple to implement these things.
To handle the `nesting' of C you've got to handle, not only {}, () and
[], but also understand some forms like if..else.. switch, etc.
But C does have its syntax rules too. 

I would assume that Gnuemacs would have a pretty decent C mode.  Am I
wrong? Is this less commonly used/known than the equivalents in the Lisp
world?

Ok, have fun...I can take it...
bruce



More information about the Comp.lang.c mailing list