Clojure JIRAhttp://dev.clojure.org/jira
This file is an XML representation of an issueen-us4.464925-07-2011[CLJS-27] Conditional compilation (or reading)http://dev.clojure.org/jira/browse/CLJS-27
ClojureScript<p>As people start trying to write libs that are portable between Clojure and ClojureScript they might need to have a bit of branching on target. N.B. supporting this means a change to Clojure, although it has general utility there as well.</p>
<p>Consider CL #+ #- reader macros - <a href="http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm">http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm</a></p>
<p><b>Patch:</b> cljs-27-v6.diff</p>
<p><b>Related:</b> <a href="http://dev.clojure.org/jira/browse/CLJ-1424" title="Reader conditionals"><del>CLJ-1424</del></a>, <a href="http://dev.clojure.org/jira/browse/TRDR-14" title="Reader conditionals"><del>TRDR-14</del></a></p>CLJS-27Conditional compilation (or reading)EnhancementMajorClosedCompletedDavid NolenRich HickeyFri, 22 Jul 2011 07:38:46 -0500Thu, 9 Apr 2015 10:32:22 -0500Thu, 9 Apr 2015 10:32:18 -05000.0-31260.0-31961211
<p>The following patches include an implementation of Common Lisp's #+<br/>
and #- reader macros to allow conditional compilation/reading for<br/>
Clojure and ClojureScript.</p>
<p>The patches add a dynamic variable called <b>features</b> to the<br/>
clojure.core and cljs.core namespaces, that should contain the<br/>
supported features of the platform in question as keywords. </p>
<p>Unlike in Common Lisp, the variable is a Clojure set and not a list.<br/>
In Clojure the set contains at the moment the :clojure keyword, and in<br/>
ClojureScript the :clojurescript keyword. </p>
<p>I would like to get feedback on the names that are added to this<br/>
variable. Are those ok? Is :jvm for Clojure and :js for ClojureScript<br/>
better? Should ClojureScript add something like :rhino, :v8 or<br/>
:browser as well?</p>
<p>To run the ClojureScript tests, drop a JAR named "clojure.jar" that<br/>
has the Clojure patch applied into ClojureScript's lib directory.</p><p>This is an enhancement so it probably requires a design page and extended discussion before it will go anywhere. Until that happens I'm marking this is as low priority.</p><p>Ok. If someone could give me write access to the Clojure Dev Wiki I would be happy to start such a design page.</p><p>If you've sent in your CA request permissions on the clojure-dev mailing list.</p><p>I started a design page for this ticket in the Clojure Dev wiki:<br/>
<a href="http://dev.clojure.org/display/design/Feature+Expressions">http://dev.clojure.org/display/design/Feature+Expressions</a></p><p>Posting my comments over on the design page...</p><p>Latest patch updates into current ClojureScript and use of tools.reader/tools.analyzer etc. The reader changes are all in the accompanying tools.reader patch in <a href="http://dev.clojure.org/jira/browse/TRDR-14" title="Reader conditionals"><del>TRDR-14</del></a>. This patch adds support to allow a new option "features" which is expected to be a set of keywords. build will inject :cljs into this set. The feature set is maintained in clojure.tools.reader/&#42;features*. set! is enhanced to special-case an update to &#42;features* in the code (presumably a rarely-used feature). </p>
<p>Because tools.reader needs the supporting patch, I left in several changes that pull in a new version of tools.reader - I don't actually expect those to be the correct versions but they are there as a reminder to update all of the proper places.</p><p>cljs-27-v2.diff adds ability to load .clj files as well as .cljs files when compiling.</p><p>Fresh patch, switch to take .cljc files.</p><p>Freshened patch for current CLJS.</p><p>Alex the freshened patch includes modifications to the compiler version dynamic var and compiler version fn. Can we remove these? Thanks!</p><p>Yep, updated to -v5 patch.</p><p>Updated to use new tools.reader patch and to remove the ability to dynamically set the features set. The active set of features can be set on startup and are held in the <b>features</b> var in the analyzer.</p><p>the big issues resolved as of <a href="https://github.com/clojure/clojurescript/commit/7ccdffaf8f36a28dec6651248707ac83e6362d79">https://github.com/clojure/clojurescript/commit/7ccdffaf8f36a28dec6651248707ac83e6362d79</a></p>ApprovalVettedGlobal RankPatchCode and Test