Something else which is against classes: incorrect scope
behaviour:

[code]
import std.stdio;

class TestC {
public:
        this() {
                writeln("CTOR class");
        }

        ~this() {
                writeln("DTOR class");
        }
}

struct TestS {
public:
        this(int i) {
                writeln("CTOR struct");
        }

        ~this() {
                writeln("DTOR struct");
        }
}

void main() {
        {
                writeln("begin scope");

                TestC c  = new TestC();
                TestS s = TestS(42);

                writeln("end scope");
        }

        writeln("end main");
}
[/code]

Prints

begin scope
CTOR class
CTOR struct
end scope
DTOR struct
end main
DTOR class

Why comes "DTOR class" _after_ "end main" and not before?
If i write "scope TestC c = ...;" it is correct, but i read that
"scope" will be deprecated. Can someone explain me that behaviour?

Reply via email to