Damian Conway writes:
: > Larry>     @result = for @a; @b -> $a, $b { $a op $b }
: > 
: > Larry> (presuming we make C<for> actually act like C<map>).
: > 
: > Why not just make map do that?
: 
: The order of C<map>'s arguments is wrong. To make the -> extraction
: syntax work we need the data being iterated to be on the left and the
: processor block (actually a closure in Perl 6) to be on the right.

Well, that's not insurmountable, but it would require parens if we
stuck with the semicolon notation.  This would find an end of statement
too soon, after the @a:

     @result = map -> $a; $b { $a op $b } @a; @b;

so it'd probably have to be written as one of

     @result = map -> $a; $b { $a op $b }, (@a; @b);
     @result = map (-> $a; $b { $a op $b }, @a; @b);
     @result = (map -> $a; $b { $a op $b }, @a; @b);
     (@result = map -> $a; $b { $a op $b }, @a; @b);

That's starting to get up there on the grottiness meter.  Since semicolon
is probably just separating lists within lists, perhaps

     @result = map -> $a; $b { $a op $b }, [@a], [@b];

is a valid alternative.  But it's still not as comely as the C<for>,
which never needs the parens, since it knows the {} is coming.

Perhaps we shouldn't be using ; for this.

Larry

Reply via email to