scope guards

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 5 02:37:57 PDT 2014


On Monday, 4 August 2014 at 14:57:44 UTC, Dicebot wrote:
> On Monday, 4 August 2014 at 04:09:07 UTC, Manu via 
> Digitalmars-d wrote:
>> Sure, scope() may be useful for this, but it seems in my 
>> experience that
>> destructors almost always perform this without any additional 
>> code at the
>> callsite.
>
> Destructors only work if:
>
> a) you already have RAII wrappers provided, otherwise it is 
> much more code to write
> b) you work with structs, class destruction is non-determenistic

b) And even then, struct destruction can be non-deterministic if 
they happen to be in a dynamic array...


More information about the Digitalmars-d mailing list