> I may have misunderstood what I've read about protocols, so please set
> me straight if the following is wrong -
> 
> On Aug 25, 11:08 pm, Stuart Halloway <stuart.hallo...@gmail.com>
> wrote:
>> I think the current behavior follows the principle of least surprise:
>> 
>> (1) bar is a function, in whatever namespace the protocol Foo is defined in
>> 
> But bar is not a single function. Multiple bars can coexist in some
> sense, right? Otherwise there's no polymorphism?

No, bar is a single function, with many specialized implementations.

>> (2) you redefine bar (perhaps by reloading the file Foo is in)
>> 
> I don't see this as bar being re-defined, rather bar is defined for
> fooed, then defined for Object

The original example didn't just define bar, it also redefined the protocol 
itself, which is the source of the confusion. If it had only defined the 
protocol. then extended it to various things, your expectation would be correct.

>> (3) you call bar and get the new behavior
>> 
> 
> It seems that the dispatch mechanism for bar is preferring Object's
> bar rather than user.fooed's bar. This is not what I expected.

No. The dispatch mechanism for bar has been discarded and replaced by a new one.

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