On Wed, Sep 27, 2006 at 10:43:00AM -0600, Luke Palmer wrote:
: Well, there are a few ways to do that:
: 
:    given lc $lang {...}
: 
:    when { lc eq 'perl' } {...}
: 
:    when insensitive('perl') {...}

With the latest change to S05 that auto-anchors direct token calls,
you can now alo write:

    when token { :i perl } {...}

By the way, your 0-ary "lc" needs to be written ".lc" these days.
In Chicago we outlawed most of the 0-or-1-ary functions since we now
have a 1-character means of specifying $_ as invocant.

: Where the last one is a user-defined function which can be written:
: 
:    sub insensitive($str) { /:i ^ $str $/ }
: 
: Such "pattern functions" can be useful in a variety of contexts.  That
: is, write functions which are designed explicitly to be used in the
: conditions of when statements.

I guess that can also now be written:

    my &insensitive ::= token ($str) :i { $str };

or maybe even

    my &insensitive ::= token :i { $^str };

Larry

Reply via email to