--- Comment #26 from Eyal <> ---
What solution is there for this use-case then?

We need objects to register themselves (i.e: set out-of-scope pointers to point
at them) and RAII-wise have them de-register themselves.  While they are
registered, we need a guarantee that they won't be moved.

Doesn't sound like D has any solution for us here?

1) We can't use classes, because:
1.A) they are hard to use without GC
1.B) cannot reasonably nest classes so they re-use the same allocation as the
container class
1.C) cannot easily allocate them on the stack

2) We can't use structs, because there's no way to make sure structs aren't
moved when they're registered.

In my experience, this use-case of registered objects is extremely common.

Immovable structs, even if those require some effort, sound like they should be
well worth virtually any effort they'd require.

In practice, we use structs for this, and we don't really have a choice so
we'll keep using structs. But D is fighting us here, instead of helping us.


Reply via email to