You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
< pmichaud> I think RT #77074 is wrong in terms of what it expects.
< pmichaud> the first @in[1] should definitely be 2, not 20
< pmichaud> because array assignment is mostly eager
< pmichaud> I think it could be closed as "not a bug"
< jnthn> my @out := @in.map({$_*=10;}); # this binding means we don't
evaluate the map eagerly, since binding is not mostly eager
< jnthn> So yeah, think it's not a bug.
Migrated from rt.perl.org#77074 (status was 'rejected')
Searchable as RT77074$
The text was updated successfully, but these errors were encountered: