<< Back to previous view

[TRDR-14] Reader conditionals Created: 15/May/14  Updated: 09/Apr/15  Resolved: 09/Apr/15

Status: Closed
Project: tools.reader
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Ghadi Shayban Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: File tools.reader-feature-expressions-2.diff     File tools.reader-feature-expressions-3.diff     File tools.reader-feature-expressions.diff     File trdr-14-4.diff     Text File trdr-14-5.patch    
Patch: Code and Test
Approval: Vetted

 Description   

Reader conditionals

See: http://dev.clojure.org/display/design/Reader+Conditionals

CLJ-1424 is the accompanying patch for Clojure.

Patch: trdr-14-5.patch



 Comments   
Comment by Nicola Mometto [ 19/May/14 6:56 PM ]

I looked over the patch and it mostly looks good, a few comments:

  • does *suppress-read* need to be exposed?
  • can you add a docstring for *features*?
  • should *suppress-read* affect read-eval?

That said, has it been decided that this is how feature expressions will be implemented in 1.7?
If not, I'm going to wait to merge this in until a decision is taken, this is a major design point and I don't want to diverge from the official clojure take on this even for a single release: people might start using it, especially since t.r is now the default reader for cljs.

Comment by Ghadi Shayban [ 19/May/14 7:23 PM ]

Yes thank you for not merging. This is WIP and just one approach for feature expressions. There seem to be at least two couple diverging approaches emerging from the various discussion (Brandon Bloom's idea of read-time splicing being the other.) I would definitely not merge until the community and Rich weighs in.

In any case having all Clojure platforms be ready for the change is probably essential. Also backwards compatibility of feature expr code to Clojure 1.6 and below is also not trivial.

1) *suppress-read* probably doesn't need to be exposed
2) *suppress-read* should probably imply *read-eval* false. You wouldn't want read-ctor to load any classes or call any code or constructors

Comment by Alex Miller [ 04/Aug/14 12:56 PM ]

Updated patch to reflect clj and cljs as initial feature names.

Comment by Alex Miller [ 21/Jan/15 4:34 PM ]

Attached new patch trdr-14-4.diff that uses an explicit options map with a :features key to a set of features. These changes match the latest changes in clj-1424, which are patterned after a similar implementation in the Clojure edn reader.

Comment by Alex Miller [ 08/Apr/15 2:10 PM ]

trdr-14-5 patch is a port of the reader conditional patch at CLJ-1424. It was no fun.

Comment by Alex Miller [ 08/Apr/15 2:22 PM ]

two things I'm uncomfortable with:
1) use of LinkedList. it matches the Clojure version but relying on that stateful Java class is gross.
2) the READ_EOF and READ_FINISHED definitions - it's probably better to use (Object.) and identical? than what I'm doing now.

Comment by Alex Miller [ 08/Apr/15 3:22 PM ]

From Nicola: return-on-value is always READ_FINISHED - can we hard-code and remove from the signature?

Comment by Nicola Mometto [ 08/Apr/15 5:11 PM ]

WIP in the reader-conditionals branch https://github.com/clojure/tools.reader/tree/reader-conditionals
The additional commits on top of 7db11b110770d7c3925194a89baa8b8a773bf431 address the concerns reported by Alex in previous comments (except the use of LinkedList) and make tools.reader use the existing ReaderConditional and TaggedLiteral when available, fallbacking to a custom version when not.

This is the same approach tools.reader uses for ExceptionInfo on clojure 1.3.0 and seems to me a better approach than using different types than clojure itself (when they are available) but I'd like some feedback on this (commit 2c3adbe4c4f0fab8087380ff0dbb1ad44c8739e1)

The additional commits also fix a couple of bugs wrt handling of eof

Generated at Wed Sep 02 17:02:51 CDT 2015 using JIRA 4.4#649-r158309.