On Fri, 02 Jun 2017 15:43:07 -0700, c...@zoffix.com wrote:
> Normally, if you sink a .map, it gets eagerly evaluated:
> 
>     <Zoffix__> m: <a b c>.map: &say
>     <camelia> rakudo-moar ef9872: OUTPUT: «a␤b␤c␤»
>     <Zoffix__> m: for ^1 { <a b c>.map: &say; $ = 42 }
>     <camelia> rakudo-moar ef9872: OUTPUT: «a␤b␤c␤»
> 
> However, this doesn't happen when the map is the last value of
> a sunk Promise:
> 
>     <Zoffix__> m: start { <a b c>.map: &say }; sleep 2;
>     <camelia> rakudo-moar ef9872: ( no output )
> 
The last statement of a start block is not in sink context, because it becomes 
the result of the Promise. Sinking a Promise doesn't do anything (and certainly 
does not block on the result so it can sink it). You should always `await` or 
`whenever` a Promise or otherwise use its result (`.then(...)` for example), 
otherwise errors are also lost. So, this works as designed, and the program is 
at fault for not using the result of the Promise.

Maybe some future Perl 6 version will handle start blocks in sink context 
differently (for example, giving them an error handling that brings down the 
program), but that's speculative at this point and we certainly can't do it 
without causing regression in 6.c.

Reply via email to