Skip to content

Instantly share code, notes, and snippets.

@Bronsa
Created August 4, 2012 21:20
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 Bronsa/3260031 to your computer and use it in GitHub Desktop.
Save Bronsa/3260031 to your computer and use it in GitHub Desktop.
(def AFn
(list
'java.lang.Callable
'(call [this] (-invoke this))
'java.lang.Runnable
'(run [this] (-invoke this))
'IFn
(map (fn [args] (list '-invoke (vec (cons 'this args))
(list 'throw-arity 'this (count args))))
(cons [] (take-while seq (iterate rest (repeat 18 '_)))))
'(-apply [this arglist]
(let [arglist-len (count arglist)]
(if (< arglist-len 19)
(eval `(-invoke ~this ~@arglist))
(eval `(-invoke ~this ~@(take 19 arglist) '~(drop 19 arglist))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment