On 14/10/2018 2:08 AM, Atila Neves wrote:
"Fun" fact: it's not @safe to "new" anything in D if your program uses any classes. Thing is, it does unconditionally thanks to DRuntime.

I hardly ever use classes in D, but I'd like to know more about why it's not @safe.

void main() @safe {
    Foo foo = new Foo(8);
    foo.print();
}

class Foo {
    int x;

    this(int x) @safe {
        this.x = x;
    }

    void print() @safe {
        import std.stdio;

        try {
            writeln(x);
        } catch(Exception) {
        }
    }
}

Reply via email to