ANSI C and comment preprocessing

Blair P. Houghton bhoughto at hopi.intel.com
Tue Jan 8 17:48:04 AEST 1991


In article <11228 at cae780.csi.com> donald at cae780.csi.com (Donald Maffly) writes:
>	"[...] comments are replaced by a single space;"
>
>Can anyone help me answer this koan????

It's not a koan, it's a feature.

ANSI standardized existing practice; i.e., there were relatively
few compilers that replaced comments with no whitespace (i.e.,
most considered comments to be whitespace).  The philosophy is
that it is legal to put a comment only where it would be legal
to put whitespace, and it's more important to adhere to this
philosophy than to enable an obfuscatory feature, and whitespace
is not legal within identifiers, therefore if there's a comment
there it's considered whitespace.

Did it break existing code?  Sure it did, but such code was
unportable to all but a few platforms, anyway.

As compensation, however, ANSI included explicit token-pasting.

				--Blair
				  "I asked, 'Master, why should I code
				   for(;;) when what I mean is while(1)?'
				   and the master said, 'the pot of tea
				   comes with hot water at no additional
				   charge,' and I was enlightened."



More information about the Comp.lang.c mailing list