In D, kann ich direkt auf Deklaration initialisieren und erwarten, dass die Initialisierungsausdrücke Teil des Konstruktors sind? Ich kam von C# und da ist das der Fall. Aber mit DMD 2.071.0 bekomme ich anderes Verhalten.Sind Initialisiererausdrücke Teil des Konstruktors in D?
class Other { }
class Test { Other nonStaticMember = new Other; }
void test()
{
auto t1 = new Test;
auto t2 = new Test;
// Assert is failing, the two Test instances are
// being initialized to the same reference
// instead of execute the Other constructor twice.
assert(t1.nonStaticMember !is t2.nonStaticMember);
}
Wenn dies das intented Verhalten hier dokumentiert werden sollen: https://dlang.org/spec/class.html richtig?