Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-22 Thread dimitris
Ok, you might be right after all :(... I called :impls on the protocol and it returns a map from Class => impls-map. So my understanding was not not quite right...Yes, you can extend the same protocol in multiple namespaces, but for *distinct* types only! So basically in my case, i need to cop

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-22 Thread dimitris
Hi Carlo thanks for you reply... Quoted from clojure.org/reference/protocols: /Avoid the 'expression problem' by allowing independent extension of the set of types, protocols, and implementations of protocols on types, by different parties./ What you said about protocol extensions being glob

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-22 Thread Carlo Zancanaro
Hey Dimitris, I think what you're running into here is a fundamental misunderstanding of protocols. Specifically, this is not true: As I understand it, protocol extensions are namespace-specific. In Clojure, protocol extensions are global. If you extend a protocol for a type then it doesn'

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-22 Thread dimitris
I don't fully follow, I'm afraid... I am applying a regular fn (e.g. `b/chash`) to a list of args which can be 1-2 or 2-3 for (depending on which multi-method we're talking about). The regular functions being applied, all provide two arities for the respective invocations, so everything is cov

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-22 Thread Justin Smith
if I'm not mistaken, the usage of apply in the api ns ensures that the method will only be found if "opts" is exactly one opt, otherwise the arity won't be found and that will be reported as no such method On Fri, Nov 22, 2019 at 12:37 AM Dimitrios Jim Piliouras wrote: > > Ok, here is the protoco

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-22 Thread Dimitrios Jim Piliouras
Ok, here is the protocol definition: https://github.com/jimpil/cryptohash-clj/blob/master/src/cryptohash_clj/proto.clj Here are the implementations (notice the two public fns at the end of each file): https://gi

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
on rereading I've clearly misunderstood you, I think we need to see actual code reproducing this error in order to know what failed here On Thu, Nov 21, 2019 at 3:42 PM Justin Smith wrote: > > there is no foo/x unless you defined one - the protocol function is > created by defprotocol and is not

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
there is no foo/x unless you defined one - the protocol function is created by defprotocol and is not owned by the object implementing the protocol On Thu, Nov 21, 2019 at 3:29 PM Dimitrios Jim Piliouras wrote: > > But the call-chain is api/x-with-foo => foo/x => proto/X so it does bottom > out

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Dimitrios Jim Piliouras
But the call-chain is api/x-with-foo => foo/x => proto/X so it does bottom out in the ns the protocol was defined in. It's just that the middle step could come from 3 different namespaces all containing protocol extensions. On Thu, 21 Nov 2019, 23:03 Justin Smith, wrote: > it might be helpful to

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
it might be helpful to consider that in the jvm methods are not data, and the proto function makes the method into concrete data belongs to the namespace that owns the protocol On Thu, Nov 21, 2019 at 2:58 PM Justin Smith wrote: > > if you define proto method x, it belongs to the protocol namespa

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
if you define proto method x, it belongs to the protocol namespace no matter where it is called, and calling it as if it belonged to the namespace defining the object extending the protocol will and should fail On Thu, Nov 21, 2019 at 1:57 PM Dimitrios Jim Piliouras wrote: > > Hi folks, > > This