Perl 5.20 and the fate of smart matching and given-when

There are problems with the design of smart-matching. The decision of what any given TYPE ~~ TYPE should do is most often unobvious, inconsistent and/or disputed. The idea isn’t to remove smart matching; it’s to fix it.

Specifically, ~~ will be greatly simplified, as you can see in a proposal by the 5.18 pumpking. Decisions as to how two things should match will be done with helpers such as those that already exist in Smart::Match.

... ~~ any(...)

It is much more readable, much more flexible (fully extensible), and solves a number of problems (such as “When should X be considered a number, and when should it be considered a string?”).

Leave a Comment