Created
August 4, 2012 21:20
-
-
Save Bronsa/3260031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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