I have a protocol in a crossover namespace:
(ns xxx.shared.interfaces)
(defprotocol ITimer
(seconds [timer] "Return time in seconds since timer began"))
I have an implementation for Clojure:
(ns xxx.time
(:require [xxx.shared.interfaces :refer [ITimer]]))
(defrecord Timer [start-nanos]
ITimer
(seconds [timer] (double (/ (- (System/nanoTime) (:start-nanos timer))
1000000000))))
The problem is that when I use this code in some Clojure code, having required the xxx.time namespace with :refer :all it complains it can't find seconds:
Unable to resolve symbol: seconds in this context
First of all, is it possible to share protocols in this way?
Secondly, any idea how I can make this work?
Thirdly, is this actually a good way to go about this kind of code sharing? Ideally I'd like to share the record too, but it relies on Java code, so I'd need to break that out into a function. Would that be a better way to go about this?
Thanks!