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

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

Thread Previous | Thread Next
Larry Wall
November 23, 1999 09:35
Re: [ID 19991118.014] Error producing ^\ (chr 28) with "\c\\"
Message ID:
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:


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

    /(?{ $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.


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