Peter Scott asked:

> Why give up the chance to let things that look different behave differently?

Because then you'd have to remember which order did what.
Forcing you to actually think and remember is very unDWIMical. ;-)

 
> What do [the following do]?
> 
>          @left =~ @right

Array intersection (i.e. do they share one or more element value?)
That choice facilitates:

        given @data {
                when @looking_for_one_of_these {...}
                when @or_else_one_of_these     {...}
                ...
        }


>          %left =~ %right

Hash key intersection (i.e. do they share one or more keys)?
This is really set intersection, if you use the common perl idiom
of hash keys as implementing a set.

Incidentally, the table of C<=~> comparisons (Table 1) at:

        http://dev.perl.org/perl6/apocalypse/4

suggests that hash/hash matching is equivalent to:

        match if grep exists $a{$_}, $b.keys

I hope to convince Larry that it would be better if it were equivalent to:

        match if any($a.keys) =~ any($b.keys)

so that each key is recursively C<=~>-matched against each key.

I'd prefer that because if I hope to convince Larry to allow hash
keys to be any scalar value (not just strings). That way the
"keys as a set" idiom might actually be usable.


> One can imagine useful default interpretations that are not commutative.

Certainly. But they'd also be that much harder to remember (and predict).

Damian

Reply via email to