nasser / magic

Morgan And Grand Iron Clojure
http://nas.sr/magic/
365 stars 18 forks source link

limit encoding of multimethod dispatch values in method names #165

Open timsgardner opened 4 years ago

timsgardner commented 4 years ago

This is a valid multimethod:

(defmethod some-fun
  (let [x (range 10000)
        y (interleave x x)
        z (->> (take-nth (nth x 5) y)
               (filter odd?)
               (map str)
               (map first)
               (apply str))]
    (blorpus [[z]]
      (glorpus {y x}
        (doofus {x y, y z}
          (twum #{x y z})))))
  [x]
  :hello)

as is the one produced by this macro:

(defmacro awesome-multimethod []
  (let [tetomd (the-entire-text-of-moby-dick)]
    `(defmethod some-fun ~tetomd [x#] :hello)))

but neither dispatch values should be encoded in the method class name. So if we're going to do that we should at least limit the length of the reported dispatch value.

timsgardner commented 4 years ago

We may also run into issues with ClassForName, if that's still a thing. For metaprogramming etc purposes the name of the function class should work for normal type lookup in Clojure.