On 12/20/10, Nick Voronin <elfy...@gmail.com> wrote:
> I see two aspects there: first is having destructor called at known point
> rather than arbitrarily, second is performance.
>

There's still an alternative for the first part, scope(exit):

import std.stdio;

class A
{
    ~this()
    {
        writeln("A.dtor");
    }
    void test()
    {
        writeln("test");
    }
}

void main()
{
    A a = new A();
    scope(exit)
    {
        clear(a);
    }
    a.test();
}

> test
> A.dtor
> A.dtor

Reply via email to