Oh, I understand. Works in ClojureScript as well!

I noticed that in this line

(protocols/get [_] 42)

One can safely drop the namespace qualification.

Thank you very much Matthias - this issue was certainly a blocker for me.

On Mon, Sep 3, 2012 at 5:54 PM, Matthias Benkard <mulkiat...@gmail.com>wrote:

> You have reused a name already bound in the `protocols` namespace. You
> cannot bind two things to the same var.
>
> On the other hand, precisely because namespaces are not complected with
> protocol dispatch, you can easily free the `get` identifier for your
> purposes by doing exactly what you would do if you wanted to reuse the
> identifier in some other way:
>
>     (ns protocols
>       (:refer-clojure :exclude [get]))
>
>     (defprotocol P (get [_]))
>
>     (ns app)
>     (defrecord R []
>       protocols/P
>       (protocols/get [_]
>         42))
>
> You can now call `protocols/get` by namespace qualification (or by
> importing it into the current namespace):
>
>     user> (in-ns 'app)
>     app> (protocols/get (->R))
>     42
>
>
> Matthias
>
> --
> 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 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

Reply via email to