On Mon, Oct 8, 2012 at 11:33 AM, Timothy Baldridge <tbaldri...@gmail.com> wrote: > >>> Define some implementations for specific types. >>> >>> (require '[name.stadig.polyfn :refer [defpolyfn]]) >>> (defpolyfn foo Long [exp] (inc exp)) >>> (defpolyfn foo String [exp] "Hello, World!") > > I like the idea, but it seems to go against the pattern set by multi-fns: > > (defmulti foo...) > (defmethod foo ...) > > Could we do some pattern like that? > > (defpolyfn foo...) > (extendpolyfn foo ...) > > I'm thinking about situations like testing, repls, etc. When sometimes I > actually do want to completely redefine the function. I'd like a way to > re-create the polyfn. From what I see above it looks like the creation of > the polyfn is implicit rather than explicit.
At first I had that kind of syntax, but (just like multifns) if you allowed defmulti to zap the dispatch table, then it would probably make it more difficult to interactively write code with the repl and recompiling a namespace. The only purpose of the defmulti is to define the dispatch function, and in the case of polyfns the dispatch is assumed to be on the type of the first argument, so it didn't seem there was a need for (defpolyfn foo...) (extendpolyfn foo ...). I've thought about whether there might be some use for a way to add and remove implementations from the dispatch table, or perhaps reset it. I'm open to ideas around this. Paul -- 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