[CLJS-335] user defined tagged literals in CLJS Created: 06/Jul/12 Updated: 25/Dec/12
I'm trying to make my own tagged literals for cljs, and its a rough scene. I've probably spend 15 hours trying to get this to work properly.
The quick hack of binding cljs-data-readers is a pretty bad solution, and doesn't work with cljsbuild.
One solution is to just copy the mechanism of data_readers.clj, instead calling it cljs_data_readers.clj. That would help.
A better solution is to just pass through all the tagged literals, and resolve them on the cljs side, eg `((cljs.core/get (cljs.core/deref cljs.reader/tag-table) ~tag) ~data))
That way the definition of the tags doesn't have to be repeated twice, as is done now (once in cljs.reader, and once in the clj-side cljs.tagged-literals) .
The problem with this is that clj itself is incapable of passing through undefined tags without exploding, which is also a near showstopper. Having something like cljs_data_readers.clj would get the job done in the meantime.
(another minor issue is that the cljs reader doesn't handle namespaced symbols, so in #a/b, b is what is used as the key into cljs-data-readers)
|Comment by kovas boguta [ 06/Jul/12 12:52 AM ]|
I've never used this before, so just assume everything in bold has earmuffs around it.
|Comment by David Nolen [ 30/Aug/12 7:38 PM ]|
This seems like a lot of separate issues rolled into one. Can we break this ticket apart into simpler actionable tickets?
|Comment by kovas boguta [ 15/Dec/12 10:35 PM ]|
Now that we have default-data-reader-fn, its possible to have a clean fix. Just set default-data-reader-fn to the function described above.
Should I generate a patch?
|Comment by David Nolen [ 21/Dec/12 4:58 PM ]|
What function defined above?
|Comment by kovas boguta [ 25/Dec/12 1:30 PM ]|
the function is
The proposal is to bind default-data-reader-fn to the above, in compiler.clj for the compile-file* function. And get rid of the binding for data-readers in that function as well.
It should be possible to get rid of the tagged_literals.clj file as well, since those definitions are no longer needed after this change.