-
-
Save mmower/c73f1d93528323717217 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
; fate.core | |
(ns fate.core) | |
(defprotocol Component | |
"The Component protocol is used to allow us to refer to components using a keyword | |
(the component-key) without requiring them to have a keyword field, this also has | |
the useful property that, by extending the protocol to the Keyword type we can refer | |
to components also by this keyword transparently." | |
(component-key [this])) | |
; CLJ code using fate.core | |
(clojure.core/defrecord BarComponent [x y] fate.core/Component (fate.core/component-key [this__18135__auto] :bar)) | |
; CLJS code using fate.core | |
(clojure.core/defrecord BarComponent [x y] fate.core/Component (fate.core/component-key [this__18135__auto] :bar)) | |
fails with | |
WARNING: Bad method signature in protocol implementation, fate.core/Component does not declare method called fate.core/component-key at line 1 <cljs repl> | |
clojure.lang.ExceptionInfo: set! target must be a field or a symbol naming a var at line 1 <cljs repl> {:file "<cljs repl>", :line 1, :column 1, :tag :cljs/analysis-error} | |
; however | |
(clojure.core/defrecord BarComponent [x y] fate.core/Component (component-key [this__18135__auto] :bar)) | |
; seems to work, i.e. component-key is no longer fully qualified | |
; any ideas why this difference between CLJ and CLJS? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment