On Mon, 13 Feb 2017 21:04:37 -0800, raiph wrote:
> This comment is technically redundant. And maybe not helpful. I
> apologize if it's annoying to anyone.
Not annoying, but I feel we all have thoroughly confused bdfoy by now :P
Some minor corrections:
> 4.1 `sink some.expression;`
>
> In stark contrast to implicit sink context, explicitly sinking
> `some.expression` causes Perl 6 to silently throw away whatever value
> is returned, even a Failure.
That's inaccurate. `sink Failure.new` will explode the Failure, just
like sinking it implicitly would. The behaviour you describe is a bug
that was fixed in 2016.12 release.
> 4.2 `try some.expression;`
>
> This stores any Failure in `$!`
That will store the exception the Failure contained in $!,
not the Failure itself.
> 4.3 `some.expression.so;`, `some.expression or True;` etc.
> (Though `so some.expression;` and `?some.expression;` don't work for
> some reason.)
Basically anything that ends up calling .Bool on Failure will mark it
as handled and make it non-explosive. Both `so` and `?`seem to work fine for me:
<ZoffixW> m: say ?Failure.new
<camelia> rakudo-moar b51a55: OUTPUT«False»
<ZoffixW> m: say so Failure.new
<camelia> rakudo-moar b51a55: OUTPUT«False»
> Aiui, this only became an exception because your calling code didn't
> signal "I've got this" by explicitly `sink`ing or `try`ing or testing
> a routine's return value.
> [...]
> I think that's `use fatal;`. See
> https://docs.perl6.org/language/control#fail
There are actually no failures involved in the original code. The throwage
(not failurage) happens when the *Proc* object gets sunk. Tacking
on .so sinks the produced Bool instead.
This means `try $proc.err.close` won't stop the explosion, because
`try` receives the `Proc` object and returns it; it then gets
sunk and explodes.
Cheers,
ZZ