Protocols do not create new scoping, so, no, you cannot have two protocols
with identical method names in the same namespace.

Regarding your bug, it might have been that, or it might be that merge does
not preserve the type of the record and produces a map. I'm not sure what
the expected behaviour is here, especially since you do not mention the
order of arguments passed to merge.

On Saturday, 25 October 2014, Oliver Mooney <[email protected]> wrote:

> Hi all,
>
> Do multiple protocol definitions in the same namespace have name
> collisions if they share function names? E.g. something like:
>
>     (defprotocol
>         First
>         (protofun-one [arg1])
>         (protofun-two [arg1]))
>
>     (defprotocol
>         Second
>         (protofun-one [arg1 arg2])
>         (protofun-two [arg1 arg2]))
>
> I had to rename the second declarations for the compiler to find them,
> even though the type it was dispatching on was different (not to mention
> the arities being different, but presumably on the type counts for
> dispatching).
>
> Discovering this was followed up with one of the most infuriating bugs
> ever, where I was using merge to update a record with a map in a factory
> function, but after doing so the type was no longer being dispatched on
> properly (I was receiving errors like "No protocol method [...] defined for
> type : [object Object]. This was resolved by commenting out the merge from
> the factory function, re-compiling, un-commenting the merge function,
> re-compiling again and then it worked (I'd tried a lein clean previously).
>
> Any hints on debugging this kind of stuff would be appreciated! Or does it
> all flow from my having two protocols with overlapping function names
> defined in the same namespace?
>
> Thanks,
> Oliver.
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:;>.
> To post to this group, send email to [email protected]
> <javascript:;>.
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to