C needs reliable comments

Guido van Rossum guido at cwi.nl
Fri Jan 18 02:31:38 AEST 1991


dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:

>Did you realize
>that C is one of the few programming languages, perhaps the only one,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>in which you can never be sure of correctly commenting stuff out?

Oh?  I think you are being facetious.

Do comments in Pascal nest *according to the standard*?  I don't think so.

In standard Algol-60 the only form of comment begins (or should I use
past tense, 'began'?) with the keyword 'comment' and ends (ended) at the
first semicolon.  Pretty hard to comment out things there, too.

Algol-68 uses the same token to begin and to end comments.  It has three
or four variants ('comment', 'co' and #) but you'll have to scan the
stuff you want to comment out to be sure that there aren't occurrences
of the token you choose.

In fact in any language where comments nest you have to worry about
comment tokens occurring inside strings, unles it has a very weird
lexical structure.

--Guido (I'm sure I must have missed a smiley face somewhere...)



More information about the Comp.std.c mailing list