On Tue, Sep 8, 2015 at 9:31 PM, William la Forge <laforg...@gmail.com>
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.
>

This is because you are using the "method" access. That is only available
when the protocol is extended as interface. As example you can not use this
way (a method access to the protocol) if you extend the type/class using
`extend` or `extend-protocol`.

For remove reflection, you should add the appropriate type hint with the
`aatree.nodes.INode` interface (generated automatically when you are
defining the protocol).

If you have plans for using it always as interface (by method access),
maybe you should use `definterface` instead.


>
> 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.
>



-- 
Andrey Antukh - Андрей Антух - <n...@niwi.nz>
http://www.niwi.nz
https://github.com/niwinz

-- 
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.

Reply via email to