On 3 November 2017 at 02:31, Didier <didi...@gmail.com> wrote: > Wow, thanks. Is that all tribal knowledge? Or is there some documentation > around the Clojure interfaces and their semantics somewhere I could read? > Maybe even a Clojure book recommendation that covers this? >
Each of the internal methods corresponds to an public function: IMeta.meta => clojure.core/meta IObj.withMeta => clojure.core/with-meta IRef.alterMeta => clojure.core/alter-meta! IRef.resetMeta => clojure.core/reset-meta! So in the case of the metadata interfaces, it's pretty straightforward to figure out what they do by reading the API docs. > So if I understand correctly, withMeta will return a new object which is > not equal to the old. So two immutable objects implementing IObj which > differ only in meta are not equal. But this is a convention, in that if I > implement IMeta myself, I should also override equals so that it returns > false when meta differs correct? > Metadata doesn't affect equality (see the docs on metadata <https://clojure.org/reference/metadata>), so even though the object *identity* will differ when you use with-meta, they will be considered to be equal: user=> (def m1 {:a 1}) #'user/m1 user=> (def m2 (with-meta m1 {:x 2})) #'user/m2 user=> (= m1 m2) true user=> (identical? m1 m2) false -- James Reeves booleanknot.com -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.