On 27 Jan 2016 10:44 AM, Peter Pentchev wrote:
> On Wed, Jan 27, 2016 at 10:32:46AM -0500, Felipe Gasper wrote:
> [snip]
>> But, what is the point of $! at all? The exception is given to the CATCH
>> block as $_. If I want access to it outside CATCH, isn’t the expected
>> workflow to save CATCH{$_} to a variable, the way my example does it?
>
> Well, it makes it possible to write this concise thing:
>
> try my $f = open ...;
> die "Could not open $fname: $!" if $!;
>
Well, the problem there is that we shouldn’t have to check for failures;
failures should check whether we handled them!
Could it not be:
try my $f = open(...) or die …
??
Personally, I don’t mind eval {} in Perl 5; I just $@ were
dynamically-scoped the way $1, $2, etc. are. That would solve most of
the issues with it.
Unrelated, but, does open() not throw on failures anyway? (Noodling with
the perl6 REPL just now seems inconclusive.)
-F