> I have to wonder how many people actually like this syntax, and how
> many only say they do because it's Damian Conway who proposed it.
> And map/grep aren't "specialized syntax", you could do the same
> thing with a sub with a prototype of (&block, *@list).

I have to say that I am not specially entusiasthic about the <~ 
syntax.

I'd feel more confortable with a "plain" OO syntax:


   @out = @in.grep({...}).map({.....}).grep({...});


But my prefered option would be to ban "map" and "grep" alltogether, 
replacing them with a non-void context "for", enhanced with a "where" 
clause:


 @out = for @in where {...} { 
        ...
 }


The simplest cases don't get so horrible:


 @out = map { $_* 2 } @in;           # P5
 @out = for @in { $^a * 2 };         # P6

 @out = grep { $_ > 0 } @in;         # P5
 @out = for @in where { $_ > 0 };    # P6


(Notice the implied {$_} in the for body)

And if you are really planning to chain nine different greps/maps/.. I 
am afraid no amount of beautiful or ugly syntax will help you much. 

Overall, I am worried that we are putting too much effort in creating 
"optimal" syntaxes for some very specific cases. 

This happens to be also my complain about hyperoperators (sorry for 
bringing this again). Too much syntax, for a so small value. 

I have always favoured RFC 207[1] syntax instead of hyperoperators 
because it, at least, gives you some extra power:


 @mat3 = @mat1[|i,|j] * @mat2[|j,|i]


But that's a different story,

-angel


[1] http://dev.perl.org/rfc/207.html

Reply via email to