You don't like GC? Do you?
rikki cattermole
rikki at cattermole.co.nz
Sat Oct 13 13:35:16 UTC 2018
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) {
}
}
}
More information about the Digitalmars-d
mailing list