Hi,
"TSa (Thomas Sandlaß)" wrote:
> Ingo Blechschmidt wrote:
>> Is this a bug in S29 or will this be feature removed from Perl 6
>> and you'll have to say (for example)
>>
>> use listops :mutating;
>> my @result = map { $_++; 42 } @array; # works now
>
> Why not just
>
> my @result = map -> $_ is rw { $_++; 42 } @array; # works now
right, but IIRC if you omit the signature and the ->, you're implicitly
declaring ($_ is rw):
for @array { $_++ } # works
for @array -> $_ { $_++ } # error, $_ not rw
for @array -> $_ is rw { $_++ } # works
for @array -> $a { $a++ } # error, $a not rw
for @array -> $a is rw { $a++ } # works
Pugs seems to confirm this:
my $coderef = { $_++ };
my $var = 3;
$coderef($var), # no error
say $var; # 4
If I'm wrong, and $_ is ro by default, then I like your solution very
much, as it makes my intention very clear ("look! I'll probably modify
$_ soon!"). :)
--Ingo
--
Linux, the choice of a GNU | Knowledge is that which remains when what
generation on a dual AMD | is learned is forgotten. - Mr. King
Athlon! |