I would to use something like a weak reference in clojure.
I want to keep track of the return of a particular function. Currently I am doing this using a map which is on the end of a ref. This seems to work quite well. But I would like to keep only those which are not referenced from elsewhere.
In Java I would use a weak reference, or a weak hashtable. I can't find a similar data structure in clojure. It is possible? Or should I just use a WeakHashMap from java? The values in question are clojure records. I guess I can put these into a java collection?
one of the guiding principals in Clojure is to embrace the host platform where it solves the problem. with that in mind it makes a lot of sense not to wrap the normal Java weak hash map. don't wrap for wrapping sake
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With