Okay, in light of our further discussions, here's a re-updated proposal. Note that I have incorporated what I am now thinking of as "the Golden rule", namely that an LHS overload fires first, if both sides are overloaded. But I'm reserving the right to not actually care which order the first two cases are tested for. ;-) I have also added in two overloading cases that we seemed to have so far ignored: for unambiguous Num and Str. And I'm still hoping that the final fallback case might return undef (not "") so as to differentiate "unsmartmatchable" from "smartmatchable, but didn't match". Damian ______________________________________________________________________ Smartmatch (~~) table ===================== $a $b Meaning ===== =================== ======================== ~~-ol Any [1] $a->ol_method($b) Any ~~-ol [1] $b->ol_method($a, 'rev') Any undef ! defined $a Any CodeRef, &{}-ol $b->($a) Any Regexp, qr-ol $a =~ $b Any Num, 0+-ol [2] $a == $b Any Str, ""-ol [3] $a eq $b Any Any undef (with fatalizable warning) [1] Includes junctions, whose overloading distributes the smartmatch over their elements in their several ways. [2] $b is smartmatched as a Num only if it is unambiguously numeric. That is, if and only if at least one of the following is true: a. $b contains an object with overloaded numerification, but no overloaded stringification; b. $b has an internal numeric representation but no internal string representation; c. some (as-yet theoretical) internal flag indicates that $b originally had only an internal numeric representation. [3] $b is smartmatched as a Str only if it is unambiguously stringy. That is, if and only if at least one of the following is true: a. $b contains an object with overloaded stringification, but no overloaded numerification; b. $b has an internal string representation but no internal numeric representation; c. some (as-yet theoretical) internal flag indicates that $b originally had only an internal string representation. ______________________________________________________________________ The when construct ================== Form Meaning ================== ================================== when (EXPR) {...} if ($_ ~~ (EXPR)) {...; break} when {BLOCK} {...} if ($_ ~~ sub{BLOCK}) {...; break} No exceptions. No special cases. ______________________________________________________________________Thread Previous | Thread Next