Hi,
according to S29 [1], neither map nor grep allow mutation:
multi sub Perl6::Array::map (@values, Code $expression) returns Lazy
multi sub Perl6::List::map (Code $expression : [EMAIL PROTECTED]) returns
Lazy
multi sub Perl6::Array::grep (@values : Code *&test ) returns Lazy
multi sub Perl6::Array::grep (@values, MatchTest $test ) returns Lazy
multi sub Perl6::List::grep (MatchTest $test : [EMAIL PROTECTED]) returns
Lazy
OTOH, Perl 5 did allow it:
my @array = (0, 1, 2, 3);
my @result = map { $_++; 42 } @array;
print @result; # 42424242
print @array; # 1234
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
What about reduce? (FWIW, I'd like it to allow mutation.)
What about sort? (FWIW, I'd like it to not allow mutation,
as allowing mutations would probably prevent many
optimizations.)
Opinions?
--Ingo
[1] http://svn.openfoundry.org/pugs/docs/AES/S29draft.pod
--
Linux, the choice of a GNU | "The future is here. It's just not widely
generation on a dual AMD | distributed yet." -- William Gibson
Athlon! |