Other is a more complex version (wrapping) of What. It does what What does but much more. I took care to define 2 namespaces.
(ns what)
(defprotocol IWhatever
(whatever [this]))
(deftype What []
IWhatever
(whatever [this]
(str "whatever")))
(whatever (->What))
(ns other (:require what))
(deftype Other []
what/IWhatever
(whatever [this]
(what/whatever (what/->What))))
(whatever (->Other)) ;bad line
The error is:
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: whatever in this context, compiling:(C:\...)
Why won't this last expression resolve? It's like the name can't be found, but as you can see I redefined it under the current namespace.
It's nonsense code but I used the simplest example of the problem to illustrate the point. I'm running this in LightTable if that's relevant.
Qualify the final line with the namespace of where the protocol was defined. I kept thinking to try to call the whatever method in the other namespace since it was defined there.
(what/whatever (->Other))
Thanks goes to @soulcheck and everyone else who took time to help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With