On Thursday, February 16, 2017 at 6:40:41 PM UTC+1, Dustin Getz wrote: > My expectation is the compiler, when it sees `(def foo #DbId [1 2])` will > emit javascript equal to `(def foo (hypercrud.types/read-DbId [1 2])`
Your assumption is incorrect. I cannot answer your question since I have not used data_readers.cljc in CLJS. I have however used it in Clojure and my one and only recommendation is: DON'T! Don't get me wrong, tagged literals are excellent when it comes to data. Not so much for code though. Lets look at two variants of code that achieve the same thing: data_readers.cljc (ns my.app) (def foo #Dbld [1 2]) vs. just plain CLJ(S) (ns my.app (:require [hypercrud.types :as t])) (def foo (t/dbld 1 2)) These both achieve the same thing. However the non-tagged version is self contained. It does not need anything else to run. You can eval it in a REPL and it will work. You can see which namespaces are involved and which function is called. The data literal version however cannot run without setting up an environment. It must read the data_readers.cljc and eval things (at READ time). Have fun debugging this. The trouble with this for CLJS is also that you now must teach the compiler about all your objects. Since it must learn what code to emit so your object can be constructed by the JS runtime. So my warning is to never use tagged literals for code. For data you can use the :readers opts in clojure.edn/read-string [1]. CLJS has (cljs.reader/register-tag-parser! "tag" parse-fn) or the same as above if you are using tools.reader. YMMV, /thomas [1] https://clojure.github.io/clojure/clojure.edn-api.html -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at https://groups.google.com/group/clojurescript.