In Perl 5, for (reverse @foo) { $_ = $_ + 1 }
actually works. But reverse does not return lvalues, which means that: (reverse @foo) = map $_ + 1, @foo; does not do the same thing, but actually throws an exception. I think, but haven't confirmed, that the for-reverse is an optimization resulting in an undocumented feature. This is something I hope Perl 6 will avoid, but that raises the following question: Will Perl 6 support mutable for-reverse? Some possible answers that I could think of: (a) Yes, but as a special case (b) Yes, because reverse returns lvalue aliases (c) No But there's another one, that I didn't immediately think of: (d) Yes, because reverse @foo always behaves like an array (rather than a function that *returns* a list), just with a different view: the elements are in the wrong order. This option d is interesting, and would probably be nice to have, because it would also allow this (contrived and useless) kind of thing: push reverse(@foo), $bar; And while that isn't very interesting, I think something like my @bar := reverse @foo; would be very useful. Insert an element between positions 1 and 2, and the original @foo array gets them between positions -3 and -2. The same thing would be interesting for zip: my @xyzzy := @foo Y @bar; Assuming this results in an even number of elements in @xyzzy, pushing a single element onto @xyzzy could result in an element added to @foo every odd, and to @bar every even time. Would something like that be possible? Wanted? Not too costly? Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html