On Sat Sep 06 06:31:08 2014, moritz wrote: > <moritz> m: my @outer = 0..3; await my $x = start { eager @outer.map: > *+1 }; say $x.result.perl > <camelia> rakudo-moar 4a7429: OUTPUT«(1, 2, 3, 4).list» > <moritz> m: my @outer = 0..3; await my $x = start { @outer.map: *+1 }; > say $x.result.perl > <camelia> rakudo-moar 4a7429: OUTPUT«().list» > > Same result on the JVM. > > I guess this is related to the generator being scheduled on the old > thread that has already terminated, or something like this. > > Anyway, it shouldn't silently swallow the contents of a lazy list.
After the GLR, it whined about the Seq already having been iterated. I've now fixed that (turns out Promise!keep was actually sinking the Seq). Note that it's important to use the value that comes back from await, *not* to have the await in sink context and then call .result. Why? Because then you end up sinking the thing that await hands back. So, this (after my fix) is now fine: my @outer = 0..3; say await start { @outer.map: *+1 } This even with my fix isn't (by design) going to work: my @outer = 0..3; my $p = start { @outer.map: *+1 }; await $p; # sinks the result say $p.result; # Seq already consumed by the sink above Since a Seq is one-shot. You can create this situation easily enough without Promises being involved, however - that's the nature of Seq. Corrected tests unfuged in S17-promise/start.t, and added another one golfed from an example on IRC.