ClojureScript

user defined tagged literals in CLJS

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

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)

Activity

Hide
kovas boguta added a comment -

I've never used this before, so just assume everything in bold has earmuffs around it.

Show
kovas boguta added a comment - I've never used this before, so just assume everything in bold has earmuffs around it.
Hide
David Nolen added a comment -

This seems like a lot of separate issues rolled into one. Can we break this ticket apart into simpler actionable tickets?

Show
David Nolen added a comment - This seems like a lot of separate issues rolled into one. Can we break this ticket apart into simpler actionable tickets?
Hide
kovas boguta added a comment -

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?

Show
kovas boguta added a comment - 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?
Hide
David Nolen added a comment -

What function defined above?

Show
David Nolen added a comment - What function defined above?
Hide
kovas boguta added a comment -

the function is
(fn [tag data] `((cljs.core/get (cljs.core/deref cljs.reader/tag-table) ~tag) ~data))

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.

Show
kovas boguta added a comment - the function is (fn [tag data] `((cljs.core/get (cljs.core/deref cljs.reader/tag-table) ~tag) ~data)) 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.
Hide
David Nolen added a comment -

Is this still an issue today?

Show
David Nolen added a comment - Is this still an issue today?

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: