[ANN] faster-multimethods

2017-10-12 Thread John Alan McDonald
Beta release (0.1.0) of faster-multimethods, which brings multimethod lookup overhead to roughly the same cost as protocols, with only modest changes to the Clojure 1.8.0 implementation. It is mostly backwards compatible with Clojure 1.8.0. I would very much appreciate feedback on the semantic

Re: redefining multimethods at the repl

2017-09-20 Thread John Alan McDonald
It seems to me that defmulti should create a new instance of MultiFn, initialized with the method tables from the existing MultiFn, if any. Then alter-var-root to update the Var holding the MultiFn. A possible problem is that a new dispatch function might be inconsistent with the existing keys a

functions with metadata, 2 problems: performance hit and equality not preserved.

2017-09-19 Thread John Alan McDonald
I'd like to be able to do something like: (defn square ^double [^double x] (* x x)) (def meta-square (with-meta square {:domain Double/TYPE :codomain Double/TYPE :range {:from 0.0 :to Double/POSITIVE_INFINITY :also Double/NaN}}) https://clojure.org/reference/metadata says "Symbols and collection

Re: Question about transitivity in MultiFn.prefers() --- possible bug

2017-08-14 Thread John Alan McDonald
A related but slightly different issue: is prefer-method supposed to be transitive? That is, (prefer-method f a b) and (prefer-method f b c) implies (prefer-method f a c)? Here is a unit test that checks for transitivity (which fails in Clojure 1.8.0): (test/deftest transitive (derive ::tra

MultiFn.prefers() ignores the multimethod's internal hierarchy

2017-08-12 Thread John Alan McDonald
prefers(x,y) visits ancestors by calling parents.invoke() recursively. This visits the parents in the global hierarchy, not the multimethod's hierarchy. Is this the intended behavior? Why would that be? On the assumption that prefer-method should behave the same for a local vs the global-hierar

Question about transitivity in MultiFn.prefers() --- possible bug

2017-08-12 Thread John Alan McDonald
prefers(x,y) checks the ancestors of x, and returns true if any of them are preferred to y --- which makes sense to me. However, it also check the ancestors of y, and returns true if x is preferred to any of them, which I don't understand. Is that the intended behavior? Seems like it should be