On 30/08/14 05:15, Atamert Ölçgen wrote:
Obviously I can't.

But I need to add this capability to an object. During testing I attach meta to this object that contains an atom. Then I pass this object to other functions, known in runtime. I can't use a dynamic var because all this happens within a mock function that may be retried and run in different threads.
In my case I used a list, e.g. (list obj), and used destructuring on the other side when needed, e.g. [obj :as wobj].

I have seen this: http://stackoverflow.com/questions/20724219/simplest-possible-clojure-object-that-can-accept-a-primitive-and-metadata but can't deref it since I can't change the functions that will use it later. If I wrap this object I need to be able to delegate all of its functionality to the original object.
I don't think there's a quick solution without changing the contract. Whatever solution is chosen you need to keep in mind how this will affect things like equality, hashing, and instanceof?
Perhaps these links could be a start:
https://groups.google.com/forum/#!topic/clojure/9zCGdW_Q7o8 <https://groups.google.com/forum/#%21topic/clojure/9zCGdW_Q7o8>
http://stackoverflow.com/questions/9086926/create-a-proxy-for-an-specific-instance-of-an-object-in-clojure
Also, if the meta data is just for you own use, then you might want to store it yourself in a map with weak references, or just use WeakHashMap <http://docs.oracle.com/javase/7/docs/api/java/util/WeakHashMap.html> directly. But then you'll be stateful...

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to