TSa wrote:
> Yuval Kogman wrote:
>> On Wed, Sep 28, 2005 at 11:46:37 -0500, Adam D. Lopresto wrote:
>>>thinking for a while.  In short, I propose that "use fatal" be on by
>>>default, and that "err" be turned into syntactic sugar for a very
>>>small try/CATCH block.
>> I like it a lot. It gives the advantages of both the flexible, more
>> robust try/catch, and the (locally) concise, clear error return.
> I don't like it at all. I fear, that we mix two orthogonal concepts
> just because it is convenient.

I agree with you, TSa. I'd like to add that we don't have to do without
convenience in the majority of cases:

    use fatal;

    for @files {
        my $fh = try { open $_ } err next;


* try {...} is, like Perl 5's eval {...}, *not* statement-level.
  This means you can easily wrap it around an expression.
  Particularly you can write
      my $fh = try { open $_ } err next;  # instead of

      my $fh;
      try {
          $fh = open $_;
          CATCH { next }

* Yes, "try {...} err ..." does not check the exception type, but
  the proposed "... err ..." doesn't either.

* "try { foo() } err next" will next even if foo() did not throw
  an exception, but returned undef. But I don't think that's a problem
  in most cases. One can always do:
      try { foo(); 1 }

FWIW, I also agree with Darren that "use fatal" should be on by default.


Reply via email to