Details
-
Type:
Enhancement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
Description
We ned the abilty to supply custom and default tag parsers when using cljs.reader/read-string (found in src/cljs/cljs/reader.cljs) in running ClojureScript applications.
ns prefixed tags
As per the edn specification "user tags must contain a prefix component". Currently, because (name tag) is being called, the ns prefix component is dropped when looking up the tag in *tag-table*
default reader fn
Currently, there is no support for supplying a default reader fn (akin to *default-data-reader-fn* in Clojure proper).
2 issues rolled into one?
I know this may be bad practice rolling 2 issues into one, but I do not know how to formulate the separate patches that affect the same lines of code and have the apply correctly regardless of order. If I need to correct this, please advise.
Already reported?
I know this issue was already raised in CLJS-335, but from my experience with making these modifications for a running ClojureScript app, I did not come across the fns in the files mentioned in that task. I assume this is because that had more to do with compiling cljs code, but please correct me if I'm wrong.
Along those lines, is this patch not acceptable if it doesn't fix both places at once?
Approach & Naming
I followed the approach that was already in place for tag parsers, supplying register and deregister helper fns. I was a bit torn on naming because in Clojure *default-data-reader-fn* is used, but in the existing ClojureScript code they are called tag-parser. Should the "reader" vs "parser" nomenclature be unified between Clojure and ClojureScript, or are they named differently because they are fundamentally different in some way that I am missing?
I don't think we can have a unified solution without a reader that is shared both at compile time and run time and I think the benefits today of run time support trumps the possible future convenience of compile time support. I don't think there is any good reason for the difference in naming - I'm inclined to keep things in line with Clojure as much as possible.
Happy to move forward with this one unless there are objections from others.