http://qs321.pair.com?node_id=1089464


in reply to Re: Bring back the smartmatch operator (but with sane semantics this time)!
in thread Bring back the smartmatch operator (but with sane semantics this time)!

One thing that will surprise people is that it contains no provision for numeric comparison, so by the numeric/string duality, numbers will be compared as strings.

Internally, Perl knows when to implicitly convert a number to a string and vice-verse, so a new smart match should be able to know when it's dealing with numbers.

Following the proposed "RHS decides the op", then when the RHS is an actual number, it could coerce the LHS to a number.1

Overall, I like this proposal. It is far better than loosing smart match (and, especially, given/when).

---

1In theory it could check both sides for numbers, but I would rather let the RHS blindly impose numericy on the LHS for consistency.