ID:1631544
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
I ran into an issue today where I could have used weak references as part of an audio controller. I found a previous topic that drifted onto weak references and doesn't appear to have moved anywhere.

Weak References would be a great tool to have, for example having a way to track objects (e.g. sound-effect emitters) without actually keeping them alive - for example, if I had an emitter attached to a mob that played an ambient sound I would want to be able to update the 3d sound/etc on that emitter, but if the mob released it I wouldn't want my 'master list' to then hold that emitter active when the mob it was attached to no longer exists, very easily.

tl;dr I'm requesting that /var/ref/ be implemented, much like /var/tmp.
This would make things a billion times easier than having to manually dereference everything.
++++
+
+
Bump
Bumpity Bump
The problem with this is, weak references are inherently difficult to implement. It can't simply be a matter of not increasing the refcount, because then the value would become invalid with no way of resetting it to null.

The only way I can think of for this to work would be by giving everything with a refcount a reverse list of weak-ref vars that tracked it, not only increasing memory consumption but increasing the complexity of a simple var setting.

Since this only comes up in the case of possible circular references, it seems far better to handle these cases in soft code on an as-needed basis.