On Thu, Aug 10, 2000 at 09:34:43AM -0700, Peter Scott wrote:
> At 05:11 PM 8/10/00 +0100, Graham Barr wrote:
> >I was more thinking of
> >
> >         eval {
> >                 # fragile code
> >         }
> >         else {                  # catch ALL exceptions
> >             switch ($@) {
> >                 case __->isa('IO')     { ... }
> >                 case __->isa('Socket') { ... }
> >                 else                   { ... }
> >             }
> >         }
> >         continue {
> >            # code always executed (ie finally)
> >         }
> >
> >And the only new keywords are for the switch statement.
> 
> Do you propose this solely to conserve keywords,

partly

> or is there another 
> advantage?  I find
> 
>          try {
>            #
>          } catch Exception::Thingy with {
>            #
>          } catch Exception::Whatsit with {
>            #
>          } otherwise {
>            #
>          };
> 
> considerably more appealing, especially since catch blocks can contain tens 
> of statements.  It's easier to see the exception class (not tucked inside a 
> method call), and there aren't additional block levels.

Well what is the difference between try and eval ?

The catch syntax is less flexable, if you wanted to catch two
different types with the same code you are forced to either
  * duplicate code
  * put it in a sub, which is away from the statement. This may not help readability
  * put a switch statement in the otherwise

In fact the syntax could be

  eval {
  }
  continue {
  }

  switch ($@) {
  } if $@;

I just don't see the need to make perl look like other languages just for
the sake of makeing it look like other languages.

Graham.

Reply via email to