> 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.
Thanks. I know that maps rely on equality semantics, etc. As Kevin mentioned, I expect the keys with different metadata to be compared equal, and point to the same value; my question is about replacing the metadata on the key for a particular map entry. In case this helps, my use case is as follows. I'm working on search algorithms that manage maps from keys representing reachable states to values representing the cost of reaching those states. When I union two such maps, I retain the minimum value (cost) for each key (state), associng in the new key and its (lower) cost. Now, states have metadata describing the path taken to reach them. I think this is a proper use of metadata, since two states reached by different paths should be considered equal. Then, after unioning some maps, I'd like to be able to retrieve the best path associated with a state by just reading the metadata off the key. The only alternative I can see would be to store the path with the cost in a second map, but this ends up being considerably less elegant. Any other ideas/suggestions? Does this seem like a perverse use of metadata to you? Thanks, Jason --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---