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␤»

-- 
Will "Coke" Coleda

Reply via email to