I just tracked down a bug in my code, which boiled down to this:
user> ^(key (first (assoc {[] :old-val} (with-meta []
{:some :metadata}) :val)))
nil
Namely, if a map already contains a given key, when you attempt to
assoc in a version of the key with new metadata this is not recorded.
It seems that the map always retains the original key:
user> (let [x [1]] (identical? x (key (first (assoc {[1] :val}
x :val2)))))
false
user> (let [x [1]] (identical? x (key (first (assoc {x :val}
[1] :val2)))))
true
Is this desired behavior? If so, is there a better way to change the
metadata on a key than first dissoc-ing it out and then assoc-ing it
back in again with new metadata?
Thanks!
Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---