atom feed24 messages in org.perl.perl5-portersRe: fixing ~~ harder. a lot harder
FromSent OnAttachments
Ricardo SignesJul 6, 2011 2:24 pm 
Leon TimmermansJul 6, 2011 3:19 pm 
ZeframJul 6, 2011 3:25 pm 
Reverend ChipJul 6, 2011 3:31 pm 
ZeframJul 6, 2011 3:49 pm 
Reverend ChipJul 6, 2011 3:53 pm 
Ricardo SignesJul 6, 2011 4:14 pm 
ZeframJul 6, 2011 4:30 pm 
Ricardo SignesJul 6, 2011 4:36 pm 
Reverend ChipJul 6, 2011 7:05 pm 
Ed AvisJul 7, 2011 9:15 am 
Jesse LuehrsJul 7, 2011 9:19 am 
Ed AvisJul 7, 2011 9:27 am 
Reverend ChipJul 7, 2011 9:33 am 
Ricardo SignesJul 7, 2011 9:43 am 
ZeframJul 7, 2011 9:43 am 
Reverend ChipJul 7, 2011 9:50 am 
Salvador FandinoJul 7, 2011 10:42 am 
Ricardo SignesJul 7, 2011 11:56 am 
Reverend ChipJul 7, 2011 12:29 pm 
Ricardo SignesJul 7, 2011 1:02 pm 
Reverend ChipJul 7, 2011 1:15 pm 
Randal L. SchwartzJul 10, 2011 3:42 pm 
Yuval KogmanJul 16, 2011 8:13 am 
Subject:Re: fixing ~~ harder. a lot harder
From:Yuval Kogman (noth@woobling.org)
Date:Jul 16, 2011 8:13:04 am
List:org.perl.perl5-porters

There is another benefit.

A perfectly reasonable huffmanization candidate is srtuctural matching of data tuples/records, to borrow terminology from fp languages. For example [1, 2] ~~[qr/^\d w+$/, match { $_ < 3 }] or matching every hash value on the rhs side with the respectively keyed value in the lhs hash.

Since so many reasonable semantics exist I think it's best to err on minimalisms side and require explicit matchers for all scenarios and to disallow plain refs or arrays/hashes on the rhs On Jul 7, 2011 7:28 PM, "Ed Avis" <ed@waniasset.com> wrote:

Jesse Luehrs <doy <at> tozt.net> writes:

use Smart::Match 'any'; my @a = (1, 2, 3); my $x = 2; if ($x ~~ any(@a)) { ... }

I currently write

if ($x ~~ @a)

but that would stop working under the 'dumb match' proposal. However, you are saying that because 'dumb match' will still accept a subroutine ref on the RHS, Smart::Match::any(@a) would continue to work.

That would work fine, as long as the Smart::Match module itself is not made obsolete by the proposed change. But still, on the principle that easy things should be easy, the Smart::Match module would need to be part of core so that perl out of the box has an easy and obvious way to test membership of a scalar in an array.