Details
-
Type:
Enhancement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Patch:Code
-
Approval:Vetted
Description
Attachments
Activity
Stuart Sierra
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Patch | Code [ 10001 ] | |
| Approval | Vetted [ 10003 ] | |
| Attachment | CLJ-890-001.patch [ 10731 ] |
Stuart Sierra
made changes -
| Attachment | CLJ-890-002.patch [ 10737 ] |
Stuart Sierra
made changes -
| Resolution | Completed [ 1 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
Stuart Halloway
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Rough draft in
CLJ-890-001.patch:This adds reader tags like #user/foo. If the symbol following the # is namespace-qualified, or if it is one of a predefined set of built-in tags (currently empty) it is interpreted as a tag. Otherwise, it is interpreted as a class name, as in defrecord literals.
The dynamic Var *data-readers* is a map from tags (symbols) to reader functions/Vars. Each invocation of Compiler.load creates a new thread-local binding, as does the REPL. At the top of a source file, use (set! *data-readers* ...) to define the tags just for that file. For runtime invocations of the reader, use binding.
When reading a tagged literal, if the tag is not defined in *data-readers* it is added as :data metadata on the following form. If the following form does not support metadata, the tag is ignored. This causes a problem when an undefined tag is used in source code, because the compiler tries to evaluate it:
user=> #foo.bar/bar {:a 1} CompilerException java.lang.RuntimeException: No such var: foo.bar/bar, compiling:(NO_SOURCE_PATH:0) user=> (quote #foo.bar/bar {:a 1}) {:a 1} user=> (meta *1) {:data foo.bar/bar}CLJ-890-001.patch: This adds reader tags like #user/foo. If the symbol following the # is namespace-qualified, or if it is one of a predefined set of built-in tags (currently empty) it is interpreted as a tag. Otherwise, it is interpreted as a class name, as in defrecord literals. The dynamic Var *data-readers* is a map from tags (symbols) to reader functions/Vars. Each invocation of Compiler.load creates a new thread-local binding, as does the REPL. At the top of a source file, use (set! *data-readers* ...) to define the tags just for that file. For runtime invocations of the reader, use binding. When reading a tagged literal, if the tag is not defined in *data-readers* it is added as :data metadata on the following form. If the following form does not support metadata, the tag is ignored. This causes a problem when an undefined tag is used in source code, because the compiler tries to evaluate it:user=> #foo.bar/bar {:a 1} CompilerException java.lang.RuntimeException: No such var: foo.bar/bar, compiling:(NO_SOURCE_PATH:0) user=> (quote #foo.bar/bar {:a 1}) {:a 1} user=> (meta *1) {:data foo.bar/bar}