Another silly question

Doug Gwyn gwyn at smoke.BRL.MIL
Sun May 21 12:46:54 AEST 1989


In article <13234 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
>I thought it strange that X3J11 outlawed "x+ =1" ("+=" is now a single
>token), but permitted "i[a]" (on the grounds that they "saw no reason
>to forbid it").

It was never clear why the old C language reference manual said "the
two parts of a compound assignment operator are separate tokens" when
the formal grammar showed them as indivisible units.  That may have
simply been a description of the (somewhat sloppy) way the
implementation of the PCC lexer happened to work.  Another possibility
is that it was desired to guarantee that such an operator could be
constructed via preprocessing.  X3J11 allows the latter anyway.  It
seems for more likely that "x+ =1" is a typo than that it is intended.

"i[a]" on the other hand has actually been intentionally used by some
programmers, although most of us certainly don't recommend it.

>... outlawing "i[a]" would have been a small step
>towards making arrays higher-class citizens than they are.

I don't think you can ever make the existing C arrays first-class
objects without invalidating large amounts of existing correct code.
There are efforts underway to find a suitable language extension
that solves this problem (for the new class of objects provided by
the extension).



More information about the Comp.lang.c mailing list