Created
April 20, 2014 23:03
-
-
Save kurogelee/11127509 to your computer and use it in GitHub Desktop.
Clojureでproxyオブジェクトにメタ情報を付与する ref: http://qiita.com/kurogelee/items/ef22826be3577292526f
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
(def v (proxy [Object] [] | |
(toString [] (str :abc)))) | |
(with-meta v {:A 111}) |
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
java.lang.ClassCastException: user.proxy$java.lang.Object$ff19274a cannot be cast to clojure.lang.IObj |
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
(def v (proxy [Object clojure.lang.IObj] [] | |
(toString [] (str :abc)) | |
(withMeta [m] (update-proxy this {"meta" (fn [this] m)})) | |
(meta [] nil))) | |
(with-meta v {:A 111}) | |
(meta v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment