Hmm.. I hoped I could avoid this.  Multi-methods should be extended,
not copied and then extended :)
But if there is no other way, I probably settle for this cumbersome
solution..


On Jan 5, 11:21 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote:
> How about creating your own print-method multimethod in a lib of your
> own, and in your libs, excluding clojure.core/print-method and
> importing your-lib/print-method instead.
>
> Then, in your-lib, make the default print-method invocation just call
> clojure.core/print-method, create your own private hierarchy, and
> provide defmethods for those types you want to provide with your own
> implementation of defmethod ...
>
> Cant' think of something better, for now ...
>
> HTH,
>
> --
> Laurent
>
> 2010/1/5 Gabi <bugspy...@gmail.com>:
>
> > Hi
> > I am trying to extend Clojures' print-method using defmethod for a
> > library I develop.:
> > How can I do this without affecting users of my lib (i want only my
> > lib to be affected )?
>
> > (derive clojure.lang.Fn ::fn)
> > (prefer-method print-method ::fn  java.lang.Object)
>
> > (defmethod print-method ::fn
> >    [o w]
> >   (.write w "Some Fn")
>
> > This is quite nice, but I would like to use a private hierarchy for
> > the above, but cant. (print-method is defined on global hierarchy)
> > What should I do ?
>
> > --
> > 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