default tagged literal reader
Description
Environment
Attachments
Activity
Resolved.
Good point about making it set!-able. I filed that issue as a separate bug: CLJ-1101.
what about adding default-tagged-reader-fn to clojure.main/with-bindings to make it set!able?
The patch for *default-data-reader-fn* was committed for Clojure 1.5 beta1. The programmer can now specify a catch-all reader, which solves the main issue. However, there is no built-in default reader so unknown tags still cause exceptions to be thrown as in Clojure 1.4.
I think this bug can be closed. Default reader implementations could be provided by a contrib library. Or someone can open a new bug if you want the language to provide a built-in default reader.
old patches deleted. This revised patch introduces a var *default-data-reader-fn* which can be used to handle unknown tags. By default it is nil and an exception is thrown for the unknown tag as in Clojure 1.4. If it's non-nil, the function is called with the tag and value. I chose the name so that it contained 'data-reader', which makes it search friendly. I wanted to commit this separately from any attempt to provide a built-in catch-all reader and new record type as that might be more contentious.
Details
Details
Assignee
Reporter
Approval
Patch
Priority

With data reader support, it's impossible to write a program to read an arbitrary stream of Clojure forms. For example, the following code will fail with the current 1.4.0-beta1 tagged literal support:
#point [0 2]
It might be enough to require that the read side define a reader for
point
, but what if we do not wish to require that both sides of the conversation know about the#point
tag beforehand? Using theidentity
function as a default allows the reader to handle the literal form as is even when it doesn't recognize a tag (or even care to translate it).The change from the current behavior is that missing tagged literal parsers are no longer error conditions.