Paul Stadig <p...@stadig.name> writes:

Hi Paul,

> I created a library for Clojure to do open, single dispatch
> polymorphism. What does this mean?
>
> * A polyfn dispatches on the type of its first argument.
> * You can add an implementation for a new type to an existing polyfn.
> * You can define a new polyfn on an existing type.
>
> Polyfns are exactly as fast as protocol functions (I am using the same
> caching and dispatch code), but they do not generate a Java interface,
> and they are slightly simpler to define.

Sounds cool.

I have a bunch of mostly one-method-protocols that I extend upon
existing (95% java) types.  I don't rely on the existence of the
protocol interfaces, and neither do I use extends?, satisfies?, or
extenders.

Would it make sense to switch to polyfns?  Are there more advantages
except from the definitions being slightly more concise?

One minor problem I have with the protocol approach is that if you
recompile a protocol during interactive development, then calling the
protocol methods on already existing instances in your repl session of
types on which the protocol has been extended won't work anymore.  Do
polyfns help there?

Bye,
Tassilo

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