Joe English | 23 Sep 21:18

Re: TIP #329: Try/Catch/Finally syntax


Twylite wrote:
>
> Thanks for the feedback.  I've read through the paper and I agree that
> there may be a value in supporting return codes in [try/catch] ... but
> there will also be a cost.

[...]

> This is explicitly NOT the aim of TIP #329 - the exception handling
> features of Tcl are adequate (ok, they're GREAT :) ), but the syntax
> lacks readability in common cases (particular the acquire/use/close
> resource handling idiom).  The TIP seeks to define a new syntax - build
> on top of the existing exception handling facilities - to make code more
> readable in the common cases.

[...]

> This is the crux of Erlang's exception handling - the part that
> distinguishes it from C, Java and the like - the ability to define a
> "success continuation" that is outside the protection portion of code
> (the try body) and which is executed on the successful completion of the
> protected portion (where catch handlers are only executed in the case of
> failure).

Having a separate "success continuation" is what I most like
about the Erlang model, since it makes it easier to write
the acquire/use/close idiom.

> 1) Does Tcl need a syntax for "success continuation", given that it is
(Continue reading)

Mo DeJong | 24 Sep 23:27
Favicon

Re: TIP #329: Try/Catch/Finally syntax

Joe English wrote:
> The main use case for a separate success continuation is,
> in fact, the acquire/use/close case.

This is something that has always bothered me about Java's try-catch. 
There really should be
an "else" block, it would be executed when no exception is raised.

try {
  stuff
} catch {ONE ex} {
  handle it
} catch {TWO ex} {
  handle it
} else {
  no exception raised
} finally {
 cleanup
}

Working around this is a pain because one needs to create a local var 
"wasException" and set it to true in each
catch block before cleaning up in the finally block.

Mo DeJong

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
(Continue reading)

Donal K. Fellows | 25 Sep 23:00
Favicon

Re: TIP #329: Try/Catch/Finally syntax

Mo DeJong wrote:
> Joe English wrote:
>> The main use case for a separate success continuation is,
>> in fact, the acquire/use/close case.
> 
> This is something that has always bothered me about Java's try-catch. 
> There really should be
> an "else" block, it would be executed when no exception is raised.

Which is what was proposed with the 'then' clause, except for using a
different keyword of course. :-) Seems like a plan is coalescing.

Donal.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane