develooper Front page | perl.perl6.language.mlc | Postings from August 2000

Re: why not just use C /* ... */ ?

Michael Mathews
August 23, 2000 08:45
Re: why not just use C /* ... */ ?
Message ID:
Johan Vromans said
> mm> Nesting is a problem you don't really want to solve, in my opinion.
> mm> world gets real weird, real fast when you can nest and/or overlap
> mm> Not worth the trouble.
> If the prime argument for mlc is commenting out large blocks of code
> then you'd better solve the nesting problem -- and do it well.

Really, why? I have yet to hear any C or Java programmers complain about the
fact that you cannot nest /*...*/ comments.

There are no "prime arguments" here, just a collection of different points
of view.

> Especially when commenting out large blocks of code one can easily get
> into the situation that a part of a block is commented out, and then
> the whole block gets commented out. We do not want the inner comment
> to terminate the outer one, do we?

This topic has already been discussed to an extent, and actually if you read
the RFC5 you'll see that the final recommendation is for a syntax that does
allow for nesting, but I am not really satisfied with it and that's why I
don't like the idea. Here's why:

Comments should not need to be parsed by the Perl interpretter (Glenn L.
originally pointed this out). If nesting is allowed using a /*...*/ syntax,
then the parser will be forced to go through the entire comment counting
openers and closers until it gets back to zero and only then will it know
the outermost comment is ended.

This is slow. This is prone to the same kind of problem you say you want to
fix: if the random code within happens to have a stray comment opener or
closer its up to you to track down the source of your broken house of
comments (have fun!).

If however we use unique tokens to identify comment nest-levels (as RFC5
proposes) this problem goes away, only to be replaced by the problem of what
to name each new comment layer (since they must all be unique). Glen
suggests adding a time stamp to the token but you can see how tedious this
all becomes.

> In any case, commenting out large blocks (more than one visual page)
> is highly confusing unless you can clearly see what is commented out,
> for example, by prefixing every line with a '#' or so.

This is still an option, under every proposal here. No one proposing that
"there isn't more than one way to do it!"

--Michael Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About