On Fri Aug 22 09:52:24 2014, coke wrote: > On Fri Aug 20 04:39:00 2010, masak wrote: > > <blixtor> perl6: sub foo { my $s; for 1..3 { $s += $_ } } ; say foo() > > <p6eval> rakudo e45bf6: OUTPUT«666» > > <blixtor> what is the rationale for this returning '666' > > <jnthn> We embeded the devil in Rakudo. > > <jnthn> Also, for in Perl 6 is just a synonym for "map" > > <blixtor> and it's leaking from time to time, I see ;) > > <jnthn> So you're doing something like > > <jnthn> (1..3).map: { $s += $_ } > > <jnthn> Which returns $s since that's the last thing you touched > > <jnthn> So you end up with a list with $s in it 3 times > > <blixtor> ahh, ok, that explains the difference to perl5, which > > doesn't return anything > > <jnthn> Yes, it's a difference from Perl 5. > > <masak> why doesn't that return 136, though? > > <masak> that's what I'd expect. > > <sorear> masak: because Rakudo map is rw > > <sorear> it's not supposed to be > > <sorear> in theory, take should decontainerize > > * masak submits rakudobug > > <masak> it's in there, I'm sure. > > <masak> but it's nice to have this example on file. > > <sorear> like return > > <masak> aye. > > <jnthn> erm > > <jnthn> what? > > <jnthn> We never returned or taked here > > <masak> true. > > <masak> which is why it's a different ticket, I now realize :) > > <sorear> jnthn: map is implemented using take > > <jnthn> sorear: No. > > <jnthn> sorear: Well, it *may* be. > > <jnthn> sorear: But it certainly doesn't have to be. > > <jnthn> (That is, nothing in the spec says it needs to be.) > > <jnthn> morning, takadonet > > <jnthn> Anyway, it maybe should be decontainerizing somewhere here too > > <sorear> jnthn: well, in any case, the same underlying LTA is causing > > both > > <jnthn> I'm just not sure where. > > <jnthn> Anyway, a ticket does no harm and makes sure we don't forget > > the issue. > > Behavior has changed: > > 12:50 < [Coke]> perl6: sub foo { my $s; for 1..3 { $s += $_ } } ; say foo() > 12:50 <+camelia> rakudo-{parrot,jvm,moar} 60cd9d: OUTPUT«Nil»
15:57 < masak> [Coke]: https://rt.perl.org/Ticket/Display.html?id=77334 is not valid any more, at least not with that kind of for loop. 15:57 < masak> m: sub foo { my $s; ($s += $_ for 1..3) } ; say foo() 15:57 <+camelia> rakudo-moar 5bd2d4: OUTPUT«6 6 6» 15:58 < masak> [Coke]: need to do it that way instead :) So, no change, really. masak++ -- Will "Coke" Coleda