Hi Paul,
can't give you specifics but (going from memory) I might be able to point you in the right direction. take a look at the initialization code of core.matrix. you have to feed it an implementation, and it dynamically arranges bindings. sorry I can't give you more detail but I suspect you'll find your answer somewhere in that vicinity.
Gregg
Hi folks,I have a kinda basic question (I think?) that I should really know the answer to after writing Clojure for like 8 months, but don't. It's about requiring namespaces with protocol definitions in them but not the actual implementations of those protocols, and how it works.tl/dr: if a protocol is defined in namespace a and implemented (extended to the type at issue) in namespace b, can you call functions from it in namespace c where namespace c only requires namespace a, not namespace b?
Backstory: I was poking around core.matrix recently in pursuit of restarting work on a months ago issue I promised to work on, and it looks like at least one namespace calls a function it shouldn't be able to call.So: clojure.core.matrix.impl.pprint requires only one namespace within core.matrix, clojure.core.matrix.protocols. (I'm going to use ... hereafter to stand for clojure.core.matrix.) ...protocols defines a protocol PSliceSeq2, which gives the name, docstring, etc. for a function called get-slice-seq. PSliceSeq2 is actually implemented for the generic object case in ...impl.defaults and for ISeq in ...impl.sequence.But ...impl.pprint calls ...protocols/get-slice-seq. And it seems to work. Even though I can't find either ...impl.defaults or ...impl.sequence anywhere in the dependency tree for ...impl.pprint.
Cheers,
-Paul
Thanks Gregg and Alex! I didn't realize that protocols (or the black magic interfacing of core.matrix) were that fancy. Definitely going into my "code to really dig into" list.