I have also asked this question here https://stackoverflow.com/questions/34838742/weak-references-or-pointers

But I try to word it differently.

I have a game with GameObjects, a system manages those GameObjects. GameObjects can hold a pointer/reference to each other.

But at one point a GameObject dies and when it does it shouldn't be able to be accessed by other GameObjects nor should it be kept alive in memory.

How do I express this in D?

I have also looked at core.memory.GC

  auto foo = new Foo!int();
  auto foo2 = foo;
  GC.free(foo);

  if(foo != null)
    writeln(*foo);
  if(foo2 != null)
    writeln(*foo2);

But it seems that `GC.free` behaves like C++'s `delete` and doesn't actually null all the pointers.
  • Deleting an object Maik Klein via Digitalmars-d-learn

Reply via email to