I think you misunderstand, I don't think he is expecting to being able
to use :foo as a key twice with different metadata.

I think he wants something like:

(def x {[:a] 1 [:b] 2})

then

(meta (first (keys (assoc x (with-meta [:a] {:x 1}) 2))))
;(-> (assoc x (with-meta [:a] {:x 1})) keys first meta)

would be {:x 1}, instead of nil

On Fri, Apr 10, 2009 at 7:09 AM, Stuart Sierra
<the.stuart.sie...@gmail.com> wrote:
>
> On Apr 10, 12:14 am, Jason Wolfe <jawo...@berkeley.edu> wrote:
> ...
>> 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:
>>...
>> 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?
>
> Probably this is expected, since metadata is defined not to affect
> equality, and maps rely on equality semantics.  I would recommend
> against storing metadata on map keys.  In general, if the metadata
> matters for the "value" of an object, then it shouldn't be metadata.
>
> Some alternatives: 1) put the information directly in the map values;
> 2) store metadata on the map values; 3) use maps as keys.
>
> -Stuart Sierra
> >
>



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to