>>>>> "Matthew" == Matthew Walton <[EMAIL PROTECTED]> writes:

Matthew> So you're saying that in Perl 6 it will be entirely impossible to
Matthew> determine if / appears as the division operator or as the beginning of
Matthew> a regex from a purely syntactic examination of the source code?

Yes.

Matthew> I'm finding that very, very hard to believe. Regexps aren't valid
Matthew> where /-the-operator is, after all.

And that's precisely why Perl can work as it does.  If an operator is
expected, / is divide.  If a term is expected, / is the beginning of a
regex.  This has been true since Perl1 (maybe 0).  There are a few
other characters that also work similarly, but / is the most frequent
and most troublesome.  And it got worse for Perl5, because of
user-defined prototypes, which as far as I can tell, are still present
in Perl6.

Matthew> Please correct me if I'm wrong, but I've got the impression that Perl
Matthew> 6 is tokenisable without requiring BEGIN blocks to be run - provided
Matthew> no grammars which the tokeniser doesn't already know about are used,
Matthew> of course, that one will never be avoidable.

Your impression is wrong.  In the presence of user-defined prototypes,
you *must* execute the code that might alter a prototype in order to
determine whether / is a divide (and therefore standalone token) or
the beginning of a regex (and therefore must locate the end of the
regex to properly be a token).

Please see the referenced perlmonks article.

All the handwaving in the world won't fix this.  As long as we have
dual-natured characters like /, and user-defined prototypes, Perl
cannot be lexed without also parsing, and therefore without also
running BEGIN blocks.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to