> > The only extra piece of syntactic sugar that C<rx> is giving us over
> > C<rule>[*] is the ability to have arbitrary delimiters.
> 
> Not quite arbitrary. Alphanumerics aren't allowed, nor are colon or
> parens.

Aww, no alphanumerics anymore.  That's too bad; it was so nice in poetry 
to be able to write:

        m editate  and  s erpentine 

> > Or, to put it more succinctly: do there exist two pieces of
> > *syntactically correct* code like
> >   ... rule ... 
> > and
> >   ... rx ...
> > (where the ... are identical in both) which each produce *valid* and
> > *different* semantics?
> 
> Yes. For example:
> 
>       sub foo;
> 
>       foo rule ($arg) { $var := <$arg> };
>       foo rx   ($arg) { $var := <$arg> };
> 
> The first means:
> 
>       foo                     # Call foo
>           rule                # Passing a single pattern
>                   ($arg)         # That takes a single parameter
>                   {
>                       $var :=    # And binds hypothetical $var...
>                       <$arg>     # ...to what the parameter (treated as a pattern) 
>matches
>                   }
>          ;
> 
> The second means:
> 
>       foo                     # Call foo
>           rx (                # Pass, as its first argument, a pattern...
>                 $arg             # ...that matches the contents of $arg as a literal 
>string
>              )                   # No comma needed after first arg since next arg 
>is...

Hang on... I thought parens weren't allowed as delimiters.  Or does that 
not apply to rx()?

>              {                   # ...a closure...
>                 $var := <$arg>   # ...that binds $var to a stream iterator over $arg
>              }
>          ;
> 
> 
> In other words, the second is the same as:
> 
>       foo rule {$arg}, sub{ $var := <$arg> };


Luke

Reply via email to