No, try this:
import std.stdio;
class X {}
void foo(X x) { writeln(cast(void*) x); }
void main() {
X x; // null reference by default.
writeln(cast(void*) x);
foo(x);
x = new X;
writeln(cast(void*) x);
foo(x);
}
Thanks Tobias that indeed works, unfortunately storing the
address as ulong in an AA does not seem to be defeating the
garbage collector!
I guess I'll have to go for a WeakRef implementation, I'll try
Robert's implementation in signals, but I'd really like to know
how long it is likely to last as a working weak ref (in terms of
the D GC changing etc.) and if I'm taking the right approach.