/* Test the calling of the destroy method and how it interacts
 * with the perm builtin */
using namespace oadl;

class complex {
    public var real, imag;
    public proc assign(r, i) {
        real = r;
        imag = i;
    }
    public proc create(r, i) {
        real = r;
        imag = i;
        say("Creating (", r, ",", i, ")\n");
    }
    public proc destroy()
    {
        say("Destroying (", real, ",", imag, ")\n");
    }
}

proc main()
{
    var a, b;

    a = new complex(1,2);
    b = perm(new complex(3,4));
    a = nil;
    b.assign(5,6);
    b = nil;
    gc();
}