Last active
August 29, 2015 14:13
-
-
Save pmbauer/d9f25bc3b84a23c2ffe5 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
;; One example of why one might want to generate platform specific feature macros | |
;; I'm not saying this is a good DSL, just possible with https://github.com/feature-macros/clojurescript/tree/feature-macros/feature-macros-demo | |
(deftype-unified Foo [bar] | |
unified/Counted [(count [_] {:cljs (-count bar) | |
:clj (.count bar)})] | |
BazProtocol | |
(fizz [_] :buzz)) | |
;; where unified/Counted [...] expands to clojure.lang.Counted/count on :clj and ICounted/-count on :cljs | |
;; vs reified instances of #+clj #+cljs *every* *single* *time* we need to paper over implementation differences | |
(deftype Foo [bar] | |
#+clj clojure.lang.Counted | |
#+cljs ICounted | |
#+clj (count [_] (.count bar)) | |
#+cljs (-count [_] (-count bar)) | |
BazProtocol | |
(fizz [_] :buzz)) | |
;; IIR, one of Clojure's guiding design principles is to not add features that make future need X impossible | |
;; Without first-class data representation, feature expressions run counter to that principle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment