develooper Front page | perl.perl5.porters | Postings from September 2016

Re: pounding the smartmatch drum

Thread Previous | Thread Next
David Nicol
September 6, 2016 02:24
Re: pounding the smartmatch drum
Message ID:
>> The type of matching to
>> perform should be determined entirely by the rhs, and any type of
>> matching that amounts to "ask the lhs whether it matches" is too
>> surprising and not useful enough to warrant being a built-in matching
>> rule.

I agree. We already have a way to "ask the lhs whether it matches" and
that system is called method dispatch.

sub UNIVERSAL::DumbMatch{0}
sub DumbMatchOnOdd::DumbMatch{ [0,1]->[$_[1] % 2] }
$SomeObjectOrOther->DumbMatch($PretzelPattern) and say "got a pretzel";

"Teaching radical novelties is our main safeguard against
dictatorships" -- Edsger W. Dijkstra

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About