Skip to content

Instantly share code, notes, and snippets.

@samaaron
Created December 18, 2011 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samaaron/1494730 to your computer and use it in GitHub Desktop.
Save samaaron/1494730 to your computer and use it in GitHub Desktop.
Clojure: infoke overloading
(defrecord Foo [fn-impl]
clojure.lang.IFn
(invoke [this] (fn-impl))
(invoke [this a] (fn-impl a))
(invoke [this a b] (fn-impl a b))
(invoke [this a b c] (fn-impl a b c))
(invoke [this a b c d] (fn-impl a b c d))
(invoke [this a b c d e] (fn-imple a b c d e))
(invoke [this a b c d e f (fn-impl a b c d e f)])
(invoke [this a b c d e f g (fn-impl a b c d e f g)])
(invoke [this a b c d e f g h (fn-impl a b c d e f g h)])
(invoke [this a b c d e f g h i (fn-impl a b c d e f g h i)])
;;clearly needs a macro to continue...
(applyTo [this arg-list] (clojure.lang.AFn/applyToHelper fn-impl arg-list)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment