RE: Try? There is no try. -- Yoda's Exception handling syntax

2000-08-16 Thread bbehrens

I do not know what advantages the try statement would have in perl.
However, in Java programming it makes exception handling more explicit.  It
basically allows the programmer to "try" a certain action and see what the
effects are going to be (i.e. handle the exception) so that some action can
then be taken based on the results of the exception.  If no exception
happens then the code did exactly as you expected.  If not, then perhaps the
action was not appropriate for that peice of code.  This can be useful in an
OO application.

- Bradley S. Behrens

-Original Message-
From: Graham Barr [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 16, 2000 3:23 AM
To: David L. Nicol
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: Re: "Try? There is no try." -- Yoda's Exception handling syntax


On Tue, Aug 15, 2000 at 08:11:55PM +, David L. Nicol wrote:
 Would someone please enlighten me as to the purpose of an explicit "try."

In my mind it allows the important code to come before the "oh crap
something
went wrong" code.

Graham.



RE: Try? There is no try. -- Yoda's Exception handling syntax

2000-08-16 Thread Brust, Corwin

-Original Message-
From: Barrie Slaymaker [mailto:[EMAIL PROTECTED]]
[EMAIL PROTECTED] wrote:
 
 It basically allows the programmer to "try" a certain action and see what
the
 effects are going to be (i.e. handle the exception) so that some action
can
 then be taken based on the results of the exception.

Seems like any BLOCK could be an implicit eval {...} or try {...}, with the
exception handling stuff triggered by following catch or (finally|cleanup)
blocks:

   {
  kaboom ;
   }
   catch blah {
   }
   cleanup {
   }

This is like BLOCKs-as-loops.  Personally the extra 3 or 4 letters to spell
eval or try don't matter that much to me, and it would make some folks feel
more at home.  Though they could be optional, like 'return' before the
final
expression in a sub.


I like this.  M so sweet. 

Let me see If I have it...

try {...} is synonmous with eval {...} which is syntatic sugar for { ... }
any / all of which can:

contain Cthrow statments

be followed by (one or more?) catch blocks to evaluate code only if
somthing got tossed by the block

be followed by one (or more??) finally blocks containing code to be
evaluated 
requardless of the result of the  qw(try eval anon) block

So the changes, as far as diction is concerned would be:

New keywords:
try(same as eval)

catch  (same as Celse, or maybe Celsif)

finaly (same as {...})

throw  (kinda like Cdie)

The catch being that throw does some stack preservation specialness, and
probably pushes some info onto an exception stack for later unwrapping when
main goes and tries to explain what happened.

So what am I missing (please not everyone at once ;)

-Corwin




Re: Try? There is no try. -- Yoda's Exception handling syntax

2000-08-16 Thread Barrie Slaymaker

[EMAIL PROTECTED] wrote:
 
 It basically allows the programmer to "try" a certain action and see what the
 effects are going to be (i.e. handle the exception) so that some action can
 then be taken based on the results of the exception.

Seems like any BLOCK could be an implicit eval {...} or try {...}, with the
exception handling stuff triggered by following catch or (finally|cleanup)
blocks:

   {
  kaboom ;
   }
   catch blah {
   }
   cleanup {
   }

This is like BLOCKs-as-loops.  Personally the extra 3 or 4 letters to spell
eval or try don't matter that much to me, and it would make some folks feel
more at home.  Though they could be optional, like 'return' before the final
expression in a sub.

- Barrie