develooper Front page | perl.perl6.compiler | Postings from August 2010

[perl #77074] lazy rw in map

From:
Francesco Rivetti
Date:
August 7, 2010 09:25
Subject:
[perl #77074] lazy rw in map
Message ID:
rt-3.6.HEAD-3821-1281196599-1657.77074-82-0@perl.org
# New Ticket Created by  Francesco Rivetti 
# Please include the string:  [perl #77074]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77074 >


map-ed items are rw and map results are lazy, but the "lazy thing" is 
bound only to the output:

my @in = 1..4;
my @out := @in.map({$_*=10;});
say @in[1]; # expected 20, got 2
say @out[2]; # expected 30, got 30
say @in[1]; # got 20 now but may depend on implementation i think

personally i expected that -- with the introduction of rw trait on 
blocks -- for and map aren't aliasing anymore by default





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About