3 ms·
Perl smart match was a disaster because it was symmetric. Historically, smart match in Perl was "stolen" from the ideas of Perl 6. Perl 6 (now named Raku http
by lizmat 7y ago
Perl smart match was a disaster because it was symmetric.
Historically, smart match in Perl was "stolen" from the ideas of Perl 6. Perl 6 (now named Raku https://raku.org https://raku.org using the #rakulang tag on social media) learned from the problems found in Perl, and changed its smart-matching model from symmetric to asymmetric. Basically, `a ~~ b` is syntactic sugar for `b.ACCEPTS(a)`. By transferring the responsibility for what smart matching means to an object of a given class, made it possible to make much more sane default behaviour, as well as allowing authors to define their own smart-matching behaviour for custom classes.