scope guards

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 3 20:44:21 PDT 2014


On Monday, 4 August 2014 at 03:15:32 UTC, Manu via Digitalmars-d 
wrote:
> Well, then they're not particularly useful in practise. I'm 
> finding that I
> can rarely blanket an operation across all exceptions.
> The nature of exceptions is that they are of a particular type, 
> so why have
> no access to that concept when trying to respond to them...

You may have coding style particularly alien to scope guards :) 
Those are very convenient to use as a simple an generic 
alternative to RAII, especially when interfacing with C 
libraries. I find that most often one wants to catch majority of 
exceptions only in somewhat high level parts of code (i.e. main 
loop) and rest is just cleanup code - perfect fit for scope 
guards.

scope(success) is probably one I don't see use case case for 
though


More information about the Digitalmars-d mailing list