On Dec 12, 12:36 am, Ken Wesson <[email protected]> wrote: > > You can "change" the metadata on the object held by the atom (if that > object supports metadata) via (swap! a with-meta ...). > > One thing a bit annoying is if you want to alter the metadata in an > incremental way. To do that atomically requires a closure. Or defining > a swap-meta! function, like so: > > (defn swap-meta! [a f & args] > (swap! a > (fn [x] > (with-meta x (apply f (meta x) args)))))
I still very often mix up the state and identity in Clojure. What I tried to do is to add metadata to the atom itself, not to the value it holds. Now I see that it was kind of stupid:). Your swap-meta! function is of great use, from now on I will use in such cases. Thank you! Your swap-meta! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
