Hi,

Am 01.07.2011 um 00:16 schrieb Laurent PETIT:

>> On Jun 30, 2011, at 7:54 AM, Stuart Sierra wrote:
>> 
>>> Recently the received wisdom has been: protocols are a low-level 
>>> implementation detail. Actual APIs should be built with normal functions 
>>> that call the protocol methods.
> 
> But still, the functions of the protocol(s) the user will extend will
> not be those which will be called in his code.

I don't buy that. Why should protocol functions not be part of the public API?

(defprotocol Associative
  (get [this k]))

(extend-protocol Associative
  Vector
  (get [this idx] ...)
  Map
  (get [this k] ...))

Looks perfectly fine to me. In fact: how do you want to hide the protocol here? 
I think the point is that the protocol does not have to comprise the whole API. 
It can be perfectly complemented by normal functions. Or it could be just 
"internal" in terms of the user side being only normal functions (the scenario 
you describe). But I think there are relatively simple use cases (see above), 
where it doesn't have to be that way.

Sincerely
Meikel

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