Writing code that targets multiple Clojure platforms currently results in large amounts of almost-but-not-quite-the-same code, resulting in code code duplication.
;; euclidean-vector.clj(extend-protocol EuclideanVectorclojure.lang.PersistentVector...(magnitude [this](Math/sqrt (reduce + (map #(Math/pow % 2) this))))...);; euclidean-vector.cljs(extend-protocol EuclideanVectorcljs.core.PersistentVector...(magnitude [this](Math/sqrt (reduce + (map #(Math/pow % 2) this))))...)
(defn sqrt [x]
:js (Math/sqrt x)
:jvm (java.lang.Math/sqrt x)
:clr (System.Math/Sqrt x)))
- Solves problems 1, 2, 3 & 4
- No modification to the core language No or conceptual leaps
- Would break if used inside existing macros that rewrite or inspect their source, since they would see the 'feature-cond' expression rather than the evaluated platform-specific expression.
- Can't extend code you don't own
Put feature data in a global dynamic var.
- No modification to the core language
- No conceptual leaps
- Limited to symbol replacement.
New macro phase
Compiler reads metadata
Global Source rewriting
Leave it to tools / do nothing
Using the proposal, is it possible to reflect/introspect on the parsed value to see where it came from and verify that it was the result of a feature expression? See Kevin Downey's comment: http://dev.clojure.org/display/design/Feature+Expressions?focusedCommentId=5243068#comment-5243068