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

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

iain truskett
August 23, 2000 09:00
Re: why not just use C /* ... */ ?
Message ID:
* Michael Mathews ( [24 Aug 2000 01:48]:
> Johan Vromans said
> > 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.

I do. It means that in C if I want to comment out a large part of code I
tend to use an '#ifdef 0 ... #endif' preprocessor command rather than
using good ol' C /* ... */. It's messy. And Java (typically) has no
preprocessor (I usually use cpp with javac).

> 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.

Hmm. Just reread RFC5 and it doesn't really come out with a strong
recommendation of anything --- as it says "no clear concensus after [a]
week's discussion". MLCs are a good thing --- they're just tricky to get

> 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.

It's not *that* slow. Just means the parser is looking for /* as well as
*/ and is keeping track just bumping up a counter. It's not as if it's
storing the line numbers in an ever expanding list.

> 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!).

Get an editor that supports syntax highlighting (e.g. vim or emacs).
It'll improve your life no end. Makes things like this easier since it
will colour distinctly what it believes to be comment.

> If however we use unique tokens to identify comment nest-levels (as
> RFC5 proposes)...

(Amongst other things.)

> > 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!"

Just make sure you get the appropriate RFC amended to hold your views if
you think they're better. Or make a new RFC.

iain truskett, aka Koschei.                    <>
      "I'd just like to take this opportunity to say: Iain Truskett, you
      are a scheming Swine!" -- Erik Pollitt, The Barmy Army, 20000621. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About