Dustin Conrad <dustinacon...@gmail.com> writes: > Now, in the tests for heap1.clj where I am not requiring the heap2 > namespace (or even know about it), my tests are failing because > (insert nil 1) now returns a heap2 record.
Different namespaces aren’t isolated from one another. There is a single global “namespace of namespaces,” you could say. The tests for the `heap1` namespace may not have `require`d the `heap2` namespace, but e.g. under the normal Leiningen clojure.test test runner, they will both end up being loaded in the same process. Namespaces provide a way to prevent collisions between names, but all references to the same fully-qualified name refer to the same object identity. > At this point I decided I obviously did not understand what > extend-type actually does, and tried to do a bit of research, but I > couldn't really find anything that went very in-depth. The `extend-type` form mutates the collection of implementations for one or more protocol to include implementations for the extended type, replacing any existing implementations for that type. Because the protocols themselves are extended, all such extensions are globally visible to all users of the protocol. > If someone could provide an alternative to what I am trying to do, > that would be great. Alternatively, it would be useful for someone to > explain what extend-type does under the covers a bit. It’s not entirely clear what you’re trying to do, but one approach would be for each namespace to have separate nil-heap `reify`-cations of the `Heap` protocol. All local invocations of heap protocol functions would then go through proxy functions which would replace `nil` with the local nil-heap implementation. -- Marshall Bockrath-Vandegrift <llas...@damballa.com> Damballa Staff Software Engineer | 518.859.4559m -- -- 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/groups/opt_out.