try..catch..pass..finally Was: DMD 0.148 - scope guard
Stewart Gordon
smjg_1998 at yahoo.com
Tue Feb 28 08:25:10 PST 2006
Regan Heath wrote:
<snip>
> To achieve the same thing that on_scope gives with try/finally requires
> you to store state somewhere to indicate which parts of the finally
> block to execute, or, it requires that you define several finally blocks
> and nest them. Both of those options are no where near as neat as on_scope.
>
> I'm honestly baffled that people can't see the difference.
When I started to read it, it did indeed look like syntactic sugar for
try/finally. But then I realised that, as you say, it saves some of the
need to nest try/finally blocks.
on_scope_failure has another advantage still: if you have multiple catch
blocks, it saves having to replicate the recovery code in each.
Stewart.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS-
PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
More information about the Digitalmars-d
mailing list