On 2/7/06, Robin Houston <[EMAIL PROTECTED]> wrote:
>     Any     undef     undefined                match if !defined $a
>     Any     Regex     pattern match            match if $a =~ /$b/
>     Code()  Code()    results are equal        match if $a->() eq $b->()
>     Any     Code()    simple closure truth     match if $b->() (ignoring $a)
>     Num     numish[!] numeric equality         match if $a == $b
>     Any     Str       string equality          match if $a eq $b
>     Any     Num       numeric equality         match if $a == $b
>
> which retains commutativity in all cases. Of course it's
> different in Perl 6, because the "dotted entries" like
> .[number] and .method need to behave non-commutatively.
> But is it really necessary for coderefs?

My interpretation (which may be totally off, as I don't have any
confirmation that anybody else is thinking the same way I am) is that
the synopsis is wrong, and commutivity of ~~ is a happy coincidence
wherever it exists.  The way I've been thinking about ~~ is just as
the following object-oriented sugar:

    role Pattern {
        method match(Any $x) {...}
    }
    sub infix:<~~> (Any $x, Pattern $y) {
        $y.match($x);
    }

And then the interpretation of ~~ is determined by its right-hand side.

Luke

Reply via email to