ClojureScript

Conditional compilation (or reading)

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: 0.0-3126
  • Fix Version/s: 0.0-3196
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Vetted

Description

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.

Consider CL #+ #- reader macros - http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm

Patch: cljs-27-v6.diff

Related: CLJ-1424, TRDR-14

  1. cljs-27.diff
    06/Aug/14 7:39 AM
    7 kB
    Alex Miller
  2. cljs-27-v2.diff
    11/Sep/14 9:04 AM
    10 kB
    Alex Miller
  3. cljs-27-v3.diff
    07/Nov/14 10:55 AM
    10 kB
    Alex Miller
  4. cljs-27-v4.diff
    06/Jan/15 3:04 PM
    12 kB
    Alex Miller
  5. cljs-27-v5.diff
    07/Jan/15 12:28 PM
    11 kB
    Alex Miller
  6. cljs-27-v6.diff
    21/Jan/15 4:36 PM
    12 kB
    Alex Miller
  7. conditional-compilation-clojure.diff
    19/Jul/12 9:11 AM
    6 kB
    Roman Scherer
  8. conditional-compilation-clojurescript.diff
    19/Jul/12 9:11 AM
    8 kB
    Roman Scherer

Activity

Hide
Roman Scherer added a comment -

The following patches include an implementation of Common Lisp's #+
and #- reader macros to allow conditional compilation/reading for
Clojure and ClojureScript.

The patches add a dynamic variable called features to the
clojure.core and cljs.core namespaces, that should contain the
supported features of the platform in question as keywords.

Unlike in Common Lisp, the variable is a Clojure set and not a list.
In Clojure the set contains at the moment the :clojure keyword, and in
ClojureScript the :clojurescript keyword.

I would like to get feedback on the names that are added to this
variable. Are those ok? Is :jvm for Clojure and :js for ClojureScript
better? Should ClojureScript add something like :rhino, :v8 or
:browser as well?

To run the ClojureScript tests, drop a JAR named "clojure.jar" that
has the Clojure patch applied into ClojureScript's lib directory.

Show
Roman Scherer added a comment - The following patches include an implementation of Common Lisp's #+ and #- reader macros to allow conditional compilation/reading for Clojure and ClojureScript. The patches add a dynamic variable called features to the clojure.core and cljs.core namespaces, that should contain the supported features of the platform in question as keywords. Unlike in Common Lisp, the variable is a Clojure set and not a list. In Clojure the set contains at the moment the :clojure keyword, and in ClojureScript the :clojurescript keyword. I would like to get feedback on the names that are added to this variable. Are those ok? Is :jvm for Clojure and :js for ClojureScript better? Should ClojureScript add something like :rhino, :v8 or :browser as well? To run the ClojureScript tests, drop a JAR named "clojure.jar" that has the Clojure patch applied into ClojureScript's lib directory.
Roman Scherer made changes -
Field Original Value New Value
Attachment conditional-compilation-clojurescript.diff [ 11386 ]
Attachment conditional-compilation-clojure.diff [ 11385 ]
Roman Scherer made changes -
Attachment conditional-compilation-clojurescript.diff [ 11386 ]
Roman Scherer made changes -
Attachment conditional-compilation-clojure.diff [ 11385 ]
Roman Scherer made changes -
Hide
David Nolen added a comment -

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.

Show
David Nolen added a comment - 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.
David Nolen made changes -
Priority Major [ 3 ] Minor [ 4 ]
Hide
Roman Scherer added a comment -

Ok. If someone could give me write access to the Clojure Dev Wiki I would be happy to start such a design page.

Show
Roman Scherer added a comment - Ok. If someone could give me write access to the Clojure Dev Wiki I would be happy to start such a design page.
Hide
David Nolen added a comment -

If you've sent in your CA request permissions on the clojure-dev mailing list.

Show
David Nolen added a comment - If you've sent in your CA request permissions on the clojure-dev mailing list.
Hide
Roman Scherer added a comment -

I started a design page for this ticket in the Clojure Dev wiki:
http://dev.clojure.org/display/design/Feature+Expressions

Show
Roman Scherer added a comment - I started a design page for this ticket in the Clojure Dev wiki: http://dev.clojure.org/display/design/Feature+Expressions
Stuart Halloway made changes -
Patch Code and Test [ 10002 ]
Approval Vetted [ 10003 ]
Priority Minor [ 4 ] Major [ 3 ]
Hide
Stuart Halloway added a comment -

Posting my comments over on the design page...

Show
Stuart Halloway added a comment - Posting my comments over on the design page...
Alex Miller made changes -
Attachment cljs-27.diff [ 13193 ]
Hide
Alex Miller added a comment - - edited

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 TRDR-14. 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/*features*. set! is enhanced to special-case an update to *features* in the code (presumably a rarely-used feature).

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.

Show
Alex Miller added a comment - - edited 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 TRDR-14. 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/*features*. set! is enhanced to special-case an update to *features* in the code (presumably a rarely-used feature). 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.
Alex Miller made changes -
Description 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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]
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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27.diff
Andy Fingerhut made changes -
Description 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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27.diff
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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27.diff

*Related:* CLJ-1424, TRDR-14
Hide
Alex Miller added a comment -

cljs-27-v2.diff adds ability to load .clj files as well as .cljs files when compiling.

Show
Alex Miller added a comment - cljs-27-v2.diff adds ability to load .clj files as well as .cljs files when compiling.
Alex Miller made changes -
Attachment cljs-27-v2.diff [ 13330 ]
Alex Miller made changes -
Description 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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27.diff

*Related:* CLJ-1424, TRDR-14
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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v2.diff

*Related:* CLJ-1424, TRDR-14
Hide
Alex Miller added a comment -

Fresh patch, switch to take .cljc files.

Show
Alex Miller added a comment - Fresh patch, switch to take .cljc files.
Alex Miller made changes -
Attachment cljs-27-v3.diff [ 13471 ]
Alex Miller made changes -
Description 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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v2.diff

*Related:* CLJ-1424, TRDR-14
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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v3.diff

*Related:* CLJ-1424, TRDR-14
Hide
Alex Miller added a comment -

Freshened patch for current CLJS.

Show
Alex Miller added a comment - Freshened patch for current CLJS.
Alex Miller made changes -
Description 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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v3.diff

*Related:* CLJ-1424, TRDR-14
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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v4.diff

*Related:* CLJ-1424, TRDR-14
Attachment cljs-27-v4.diff [ 13719 ]
Hide
David Nolen added a comment -

Alex the freshened patch includes modifications to the compiler version dynamic var and compiler version fn. Can we remove these? Thanks!

Show
David Nolen added a comment - Alex the freshened patch includes modifications to the compiler version dynamic var and compiler version fn. Can we remove these? Thanks!
Hide
Alex Miller added a comment -

Yep, updated to -v5 patch.

Show
Alex Miller added a comment - Yep, updated to -v5 patch.
Alex Miller made changes -
Description 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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v4.diff

*Related:* CLJ-1424, TRDR-14
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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v5.diff

*Related:* CLJ-1424, TRDR-14
Attachment cljs-27-v5.diff [ 13730 ]
Hide
Alex Miller added a comment -

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 features var in the analyzer.

Show
Alex Miller added a comment - 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 features var in the analyzer.
Alex Miller made changes -
Description 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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v5.diff

*Related:* CLJ-1424, TRDR-14
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.

Consider CL #+ #- reader macros - [http://www.lispworks.com/documentation/lw50/CLHS/Body/02_dhq.htm]

*Patch:* cljs-27-v6.diff

*Related:* CLJ-1424, TRDR-14
Attachment cljs-27-v6.diff [ 13792 ]
David Nolen made changes -
Affects Version/s 0.0-3126 [ 10360 ]
Fix Version/s Next [ 10355 ]
David Nolen made changes -
Assignee David Nolen [ dnolen ]
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (12)
Watch (11)

Dates

  • Created:
    Updated:
    Resolved: