Patrick R. Michaud wrote:

On Mon, May 09, 2005 at 09:14:02AM -0700, Larry Wall wrote:

:      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.
I wonder if it's deserving of much in the way of special syntax at all,
given that we have a variety of ways to do it (closures come to mind). In the example above, one could just as easily test $1 for "don't" vs.
"every" to figure out which alternation matched. Indeed, a simple answer
is:


     m/ $<tea>:=<null>  (don't) (ray) (me) (for) (solar tea), (d'oh!)
      | $<bem>:=<null>  (every) (green) (BEM) (devours) (faces)
      /;

and then

    if ($/<tea>) { say "I hate solar tea" }
    if ($/<bem>) { say "I love bug-eyed monsters" }

Yes, I think this is the right answer. Much better not to multiply entities without necessity.


Well done, Patrick!

Damian



Reply via email to