On Sun, Apr 24, 2005 at 06:14:35PM -0700, Darren Duncan wrote: : At 4:39 PM -0700 4/24/05, Larry Wall wrote: : >On Mon, Apr 25, 2005 at 02:13:26AM +0800, Autrijus Tang wrote: : >: A while ago I posted a conflict between a block containing a pair : >: constructor, vs. a hash constructor: : >: : >: map { $_ => $_ } @foo; : > : >: And maybe it can be extended over adverbial blocks, too: : >: : >: @foo.map:{ $_ => $_ }; # closure : : Why not just always use the ':' when you are giving a block. The : block is essentially an adverb for a map|grep|sort anyway. Whereas, : no ':' means its a hash-ref. (Presumably each of map|grep|sort will : have a reasonable default adverb if no ':{}' is given.)
There are lots of blocks that shouldn't take colons. : >I really think for clarity it has to be disambiguated by either : >something syntactic on the front or something semantic at the top level. : : I agree. See my previous paragraph for an example. : : >I still : >kinda like the rule that it's a hash if the top-level looks like some : >kind of list of pairs. It optimizes for the common case. : : I agree. : : >Closures : >returning pairs are a rarity. : >Larry : : This is beside the point but ... : : Perhaps one of the new Perl 6 features makes this unnecessary, but I : often found myself doing just that when I wanted an effective method : to test multiple times if an element is in an array, like this: : : my %foo = map:{ ( $_ => 1 ) } @bar; : if( %foo{'abc'} ) ... : if( %foo{'def'} ) ... : if( %foo{'zrs'} ) ... : : That closure is returning a pair for each array element. How 'bout: [EMAIL PROTECTED] »=« 1; That seems a lot clearer to me. If you don't like hyper, how about [EMAIL PROTECTED] = (1..2:by(0)); :-) Larry