On Wed, 22 Oct 2014 18:03:44 +0000
anonymous via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

> On Wednesday, 22 October 2014 at 15:45:02 UTC, eles wrote:
> > D version:
> >
> >     { //displays ~A~B~C
> >         A foo = scoped!(A)();
> >         B bar = scoped!(B)();
> >         C caz = new C();
> >         destroy(caz);
> >     }
> >
> > Why the objects are not destroyed in the inverse order of their 
> > creation? Case in point, destroying foo releases a lock for bar 
> > and caz.
> 
> `foo` should be a `Scoped!A`. When it's typed as `A`, the
> `Scoped!A` that is returned by `scoped`, is destructed
> immediately (and the reference leaks, I guess).
yes, this is the case. i believe that this should be explicitly
documented in `scoped` ddocs. documentation examples using 'auto', but
there is no mention that this is what *must* be used.

Attachment: signature.asc
Description: PGP signature

Reply via email to