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

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

From:
iain truskett
Date:
August 23, 2000 13:51
Subject:
Re: why not just use C /* ... */ ?
Message ID:
20000824065331.A10009@eh.org
* Johan Vromans (JVromans@squirrel.nl) [24 Aug 2000 06:39]:
> iain truskett <ict@eh.org> 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\demo.java */

> t.java:1: Invalid escape character.
> /* File: C:\user\jv\demo.java */

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.


cheers,
-- 
iain truskett, aka Koschei.                    <http://eh.org/~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.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About