On Mon, May 09, 2005 at 10:33:33AM -0500, Patrick R. Michaud wrote:
: > =head2 Subpattern numbering
: > [...]
: > Of course, the leading C<undef>s that Perl 5 would produce do convey
: > (albeit awkwardly) which alternative actually matched. If that
: > information is important, Perl 6 has several far cleaner ways to
: > preserve it. For example:
: >
: > rule alt (Str $n) { {$/ = $n} }
: >
: > m/ <alt tea> (don't) (ray) (me) (for) (solar tea), (d'oh!)
: > | <alt BEM> (every) (green) (BEM) (devours) (faces)
: > /;
:
: If the C< alt > rule is accepting a string argument, the match
: statement probably needs to read
:
: m/ <alt: tea> (don't) (ray) (me) (for) (solar tea), (d'oh!)
: | <alt: BEM> (every) (green) (BEM) (devours) (faces)
: /;
This seems like a rather ugly syntax for what is essentially a label,
or a <null> rule. I wonder if we can come up with something a little
prettier. Something like:
m/ <null:tea> (don't) (ray) (me) (for) (solar tea), (d'oh!)
| <null:BEM> (every) (green) (BEM) (devours) (faces)
/;
m/ <tea:=> (don't) (ray) (me) (for) (solar tea), (d'oh!)
| <BEM:=> (every) (green) (BEM) (devours) (faces)
/;
m/ <:tea> (don't) (ray) (me) (for) (solar tea), (d'oh!)
| <:BEM> (every) (green) (BEM) (devours) (faces)
/;
or even plain label syntax:
m/ tea: (don't) (ray) (me) (for) (solar tea), (d'oh!)
| BEM: (every) (green) (BEM) (devours) (faces)
/;
if we recognize that : makes no sense as a backtrack control on a
non-quantified item.
Larry