The last thing I'd said about smartmatch was:
$x ~~ undef
$x ~~ $overloaded_object
$x ~~ sub {}
$x ~~ regex
...or fail
...with when:
when ("foo") # str eq
when (12345) # num ==
when ($x) # ~~
when { ... } # block evaluates true
when breaks the enclosing topicalizer
I wanted to post that this is a design that would get accepted. The
reservation of the final case, rather than eq/==, in smart match, lets us
figure out whether future work on improving num-v-str can be put to work here.
On the other hand, there's plenty of reason to give upon given/when/~~, too,
and I think that the one thing we might keep using would be a when-like
statement:
case (EXPR) BLOCK
equivalent to:
if ($EXPR) { BLOCK <next unless continue> }
That would be a reasonable thing to keep around if we decide we can't get to an
acceptable smartmatching future.
--
rjbs
Thread Next