Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: try ... fin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 2782 of 2841
Post > Topic >>

Re: try ... finally ...

by Joachim Durchholz <jo@[EMAIL PROTECTED] > Feb 28, 2008 at 08:34 PM

Am Donnerstag, den 28.02.2008, 11:16 +0000 schrieb Ian.Stark@[EMAIL PROTECTED]
> "David B. Benson" <dbenson@[EMAIL PROTECTED]
> writes:
> > On Feb 21, 6:05 am, rossb...@[EMAIL PROTECTED]
 wrote:
> >> http://www.ps.uni-sb.de/alice/manual/sugar.html#finally
> >
> > Very nice!  Thank you.
> 
> There's a further refinement of this in the "exceptional syntax"
> proposed by Benton+Kennedy in JFP 11(4):394-410
> 
>   http://dx.doi.org/10.1017/S0956796801004099
>   http://research.microsoft.com/~akenn/sml/ExceptionalSyntax.pdf
> 
> where you want to identify code that runs only if an exception is not
> raised.  Independently, Erlang introduced the same thing:
> 
>  try Expr of 
>    Pattern1 [when Guard1] -> Body1;
>    ...
>  catch
>    ExceptionPattern1 [when ExceptionGuard1] -> ExceptionBody1
>    ...
>  after
>    FinalBody

I have known this idiom as try-catch-finally (I think these keywords are
used in Delphi).
The point of this kind of code is that the 'after' (or 'finally') clause
is executed *even if the exception is not caught with a 'catch' clause*.
This spares you a lot of boilerplate code to catch all exceptions, undo
any resource allocations that happened during the 'try' clause, and then
either handle or rethrow the exception.
If resources are usually silently deallocated when an object is garbage
collected, this is still useful but slightly less so.

Regards,
Jo




 3 Posts in Topic:
Re: try ... finally ...
Joachim Durchholz <jo@  2008-02-28 20:34:58 
Re: try ... finally ...
Vesa Karvonen <vesa.ka  2008-02-28 19:53:49 
Re: try ... finally ...
Joachim Durchholz <jo@  2008-02-28 21:14:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 1:04:54 CDT 2008.