Frances, I have two implementations of INode, record MapNode and record VectorNode, which are defined in other files.
Also, I get a syntax method when calling new-node without the leading dot when using defprotocol: java.lang.IllegalArgumentException: No single method: newNode of interface: aatree.nodes.INode found for function: newNode of protocol: INode, compiling:(aatree/nodes.clj:51:7) On Tuesday, September 8, 2015 at 3:29:38 PM UTC-4, Francis Avila wrote: > > I don't quite understand why you are not calling the Protocol method as a > function, i.e. > > (new-node this t-2 lev l r c) > > (no leading dot on new-node). > > I also don't see anything which actually *implements* INode. > > Note that the meaning of "method" in "Protocol method" is not the same as > in "Java method": i.e. these are not Java methods called via Java interop, > although protocol implementations may create java methods on the class that > implements them in some cases (i.e. inline implementations using deftype or > defrecord) or a Java class may implement the protocol via the > auto-generated interface of the same name. You are trying to call the > "new_node" Java method directly on whatever "this" is in that context, > which requires reflection on "this" to find the implementation. > > > On Tuesday, September 8, 2015 at 1:31:10 PM UTC-5, William la Forge wrote: >> >> I'm finally looking at warn on reflection. Everything is going fine >> except in the nodes.clj file where I define a protocol, INode, with a >> method, new-node and then try to call that method from a function, revise. >> >> I'm using Clojure 1.7.0 and the file is >> https://github.com/laforge49/aatree/blob/master/src/aatree/nodes.clj >> The reflection warning occurs on line 51. >> >> Depending on what I try, either I get a class not found compiler error >> for file nodes.cli or a runtime error that new-node is NOT a member of the >> record that implements INode. I've spent hours on this and have tried many >> different things to no avail. >> >> My reason for using a method in a protocol is that I have several records >> that implement it and I'm trying to not duplicate functions which take the >> protocol as an argument. >> >> Oh yes, because I'm also using genclass, I have no option but to use AOT. >> >> On Sunday, January 12, 2014 at 8:52:14 AM UTC-5, Jim foo.bar wrote: >>> >>> there you go: >>> >>> (defprotocol IBark >>> (bark [this])) >>> >>> (in-ns 'other) >>> (set! user/*warn-on-reflection* true) >>> >>> (clojure.core/defrecord Dog [] >>> user/IBark >>> (bark [_] (clojure.core/println "WOOF!"))) >>> >>> (def d (Dog.)) >>> >>> (user/bark d) ;;NO reflection >>> >>> (.bark d) ;;reflection!!!! >>> >>> it should be obvious now :) >>> >>> Jim >>> >>> >>> On 12/01/14 13:38, Jim - FooBar(); wrote: >>> >>> It is not compiling because it cannot find the function...either fully >>> qualify it like in my previous email or change your ns declaration to >>> something like: >>> >>> [cqrs.storage :as stora] >>> >>> and then simply use stora/ret-value, stora/write, stora/write-batch >>> >>> Jim >>> >>> >>> >>> On 12/01/14 13:26, bob wrote: >>> >>> If I remove the dot, it cannot be compiled. can you give an example? >>> >>> On Sunday, January 12, 2014 9:22:00 PM UTC+8, Jim foo.bar wrote: >>>> >>>> I am suspecting you are calling the protocol implementations via the >>>> `.` >>>> form, whereas you should be going via the protocol itself (whatever >>>> namespace that may be in). >>>> >>>> Jim >>>> >>>> -- >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >>> -- 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.