Created
April 24, 2010 05:14
-
-
Save michalmarczyk/377480 to your computer and use it in GitHub Desktop.
fooling around with Clojure interfaces, part 1
This file contains hidden or 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
(deftype Foo [x y z] | |
clojure.lang.IKeywordLookup | |
(getLookupThunk | |
[self k] | |
(reify | |
clojure.lang.ILookupThunk | |
(get | |
[self k] | |
(if-let [v (k {:x x :y y :z z})] | |
(inc v))))) | |
clojure.lang.IFn | |
(invoke | |
[self k] | |
(.get (.getLookupThunk self k) k)) | |
clojure.lang.ILookup | |
(valAt | |
[self k] | |
({:x x :y y :z z} k)) | |
(valAt | |
[self k nf] | |
({:x x :y y :z z} k nf))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment