develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991118.014] Error producing ^\ (chr 28) with "\c\\"

Thread Previous | Thread Next
From:
Larry Wall
Date:
November 23, 1999 09:35
Subject:
Re: [ID 19991118.014] Error producing ^\ (chr 28) with "\c\\"
Message ID:
199911231731.JAA16685@kiev.wall.org
Philip Newton writes:
: Not quite. I want '\\' to be translated to \ in a previous pass, before
: the \c mechanism sees it. After the '\\' -> \ pass, I want left-to-right.

It would have to be done in the same pass, by pretending that \c is a
funny kind of \.  We go to great lengths to avoid doing multiple passes
in Perl, and when we do do multiple passes, we go to great lengths to
hide that fact.  For instance, we pretend that regular expressions
are interpolated and interpreted just like double-quoted strings, but
in fact, the lexer must treat them entirely differently to preserve
that illusion, because the regular expression parser does a separate
pass after interpolation.  Not only must the lexer pass backslashed
sequences through to the regular expression parser, but it has to decide
which dollar signs indicate something to be interpolated immediately:

    /$foo/

and which have to be passed through to the regular expression engine:

    /foo$/
    /(foo$|bar$)/
    /(?{ $foo += 1 })/

Actually, that last one doesn't need to pass $foo--it could conceivably
just pass a pointer to some precompiled code, but I don't think it
does.  If I recall, it's more like an eval.

But anyway, we don't cavalierly add multiple passes to Perl.  Multiple
passes tend to make things easier for the implementer, but harder for
the user.  Perl's loyalties lie with the user.

Larry

Thread Previous | Thread Next


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