Would the implementation of the smart pointer idea be possible in Mathematica ?
Let's say I have an object "o" of the form Class[object] where object is an Association, and Class has the HoldFirst attribute.
It should be easy to add to a reference count, counting the number of times "o" is stored in other variables.
But how could we decrement this reference count automatically, if it's even possible ? The goal of the reference count would be to delete object when the reference count reaches 0.
Are certain functions called under the hood by Mathematica, when deleting a list for example, and we could capture this call with an UpValues definition on Class in order to decrement the reference count ?
Or is all the memory management done at C level and we don't have to access it ?