Re: There is no such thing as IAtom

2010-12-07 Thread pepijn (aka fliebel)
Thanks all. How would I do this protocol extension thing? My guess is that I need to define the IAtom protocol myself, and then do something like this? (defprotocol IAtom (compare-and-set! []) ...) (extend-type clojure.lang.Atom IAtom (compare-and-set! []) ... IDeref (deref [])) B

Re: There is no such thing as IAtom

2010-12-06 Thread Alyssa Kwan
+1 There is no STM integration with atoms. That's not a concern. Just write your own Clojure core with your change. I did for durable identities. git://github.com/kwanalyssa/clojure.git Seriously though, just use protocols. Thanks, Alyssa On Dec 6, 5:24 am, Benjamin Teuber wrote: > I guess

Re: There is no such thing as IAtom

2010-12-06 Thread Stuart Sierra
On Dec 6, 11:52 am, "pepijn (aka fliebel)" wrote: > You can not extend them, as they are marked final. You can extend Clojure protocols to final classes. > Another point to consider is clojure-in-clojure. If that is ever going > to happen, one needs to be able to implement Atom as well. clojure

Re: There is no such thing as IAtom

2010-12-06 Thread pepijn (aka fliebel)
You can not extend them, as they are marked final. Another point to consider is clojure-in-clojure. If that is ever going to happen, one needs to be able to implement Atom as well. It is also generally better to code to an interface rather than to an implementation. Alter and send also work diffe

Re: There is no such thing as IAtom

2010-12-06 Thread Benjamin Teuber
I guess it was Rich's intention to have swap! be used for real atoms only so your code remains understandable - that's why it's called swap! for atoms, alter for refs and alter-var-root for vars. So why not define your own protocol for updating documents? If you really want (usually bad idea, I gu