in reply to Re: smart match operator should be smarter!
in thread smart match operator should be smarter!

Can you explain what those examples are supposed to demonstrate?

What I got out of it is that the naive rule is:

1) the match operator compares references.

Therefore, if you smart match @arr ~~ 2, you are doing this:

my @arr = (10, 20, 30); my $aref = \@arr; say $aref; #ARRAY(0x1810e90) 0x1810e90 ~~ 2 --output:-- NOPE!

However, the naive rule breaks down here:

my @a = (10, 20, 30); my @b = (10, 20, 30); my $aref = \@a; my $bref = \@b; say $aref; say $bref; --output:-- ARRAY(0x1810e90) ARRAY(0x181ace0) #yet... say @a ~~ @b ? 'yes' : 'no'; --output:-- yes

So you can't really say that the smart operator is comparing references, otherwise @a and @b would not match.

Replies are listed 'Best First'.
Re^3: smart match operator should be smarter!
by ikegami (Patriarch) on Nov 22, 2009 at 18:12 UTC

    Like I said, it's a different rule (ARRAY ~~ ARRAY instead of ANY ~~ NUM).