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

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

iain truskett
August 23, 2000 13:51
Re: why not just use C /* ... */ ?
Message ID:
* Johan Vromans ( [24 Aug 2000 06:39]:
> iain truskett <> writes:

> > It's not *that* slow. Just means the parser is looking for /* as
> > well as */ ...

> And "/*" and ""/*" and '/*' and qw(*/) and #*/ and \#*/ and m/.*/ ...

Of course. But see below.

> With MLC, you need to _parse_ the comments. What happens if you find a
> unterminated quoted string in a commented out section?  Guess what
> happens when you have the following comment in a java program:

>    /* File: C:\user\jv\ */

> Invalid escape character.
> /* File: C:\user\jv\ */

In that situation, I would say that the java compiler isn't really doing
what it should be doing. i.e. That looks like a bug, not a feature.  gcc
does no such thing with its comments.

> With SLC, discarding a line if it starts with a # (after optional
> whitespace) is straightforward, fail safe, and fast.

Almost. You can have # in other places on the line. It doesn't have to
be at the start (with or without whitespace).

i.e. print # this is a print statement
        $foobar # this is still the print statement
        , # a comma!
        /moo#/ # here's the comment
        ,$#array,# another one.
        q#moo# # ooh!
        ; # ok. i'm done.

You still have to parse.

iain truskett, aka Koschei.                    <>
     Q: How do I find the largest element in an array?
     A: Write a foreach elements one at a time, and stop when you get to
        the largest one.                                     -- perliaq. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About