-
-
Save harold/10dd1ba54332992b4eeab72aa88ef2bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
harold@straylight:~ []$ cd play/ | |
harold@straylight:~/play []$ mkdir cljs-edn-uuid-read-test | |
harold@straylight:~/play []$ cd cljs-edn-uuid-read-test/ | |
harold@straylight:~/play/cljs-edn-uuid-read-test []$ echo '{:deps {org.clojure/clojurescript {:mvn/version "1.10.844"}}}' > deps.edn | |
harold@straylight:~/play/cljs-edn-uuid-read-test []$ clj -m cljs.main --repl | |
Downloading: com/google/javascript/closure-compiler-unshaded/v20210202/closure-compiler-unshaded-v20210202.pom from central | |
Downloading: com/google/javascript/closure-compiler-main/v20210202/closure-compiler-main-v20210202.pom from central | |
Downloading: com/google/javascript/closure-compiler-parent/v20210202/closure-compiler-parent-v20210202.pom from central | |
Downloading: com/google/javascript/closure-compiler-unshaded/v20210202/closure-compiler-unshaded-v20210202.jar from central | |
WARNING: When invoking clojure.main, use -M | |
ClojureScript 1.10.844 | |
cljs.user=> (require 'cljs.tools.reader.edn) | |
nil | |
cljs.user=> (cljs.tools.reader.edn/read-string "#uuid \"eed86fd1-4110-44d8-8f41-27473029cc6a\"") | |
Execution error (ExceptionInfo) at (<cljs repl>:1). | |
No reader function for tag uuid. |
Neat, I didn't know about -Srepro
, thank you.
I think your second example shows that indeed cljs.tools.reader.edn/read-string
doesn't read uuids by default. Perhaps this is the expected behavior. (?)
I have the same:
$ clojure -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.844"}}}' -M -m cljs.main -e "(do (require 'cljs.tools.reader.edn) ((juxt type pr-str) (cljs.tools.reader.edn/read-string \"#uuid\\\"00000000-0000-0000-0000-000000000000\\\"\")))"
WARNING: Use of undeclared Var cljs.tools.reader.edn/read-string at line 1 <cljs repl>
Execution error (ExceptionInfo) at cljs.repl/evaluate-form (repl.cljc:577).
Execution error (ExceptionInfo) at (<cljs repl>:1).
No reader function for tag uuid.
This works, which is great:
$ clojure -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.844"}}}' -M -m cljs.main
ClojureScript 1.10.844
cljs.user=> (require 'clojure.edn)
nil
cljs.user=> (clojure.edn/read-string "#uuid \"eed86fd1-4110-44d8-8f41-27473029cc6a\"")
#uuid "eed86fd1-4110-44d8-8f41-27473029cc6a"
I can work with this. I appreciate your help.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here we can see that
clojure.edn/read-string
from cljs depends oncljs.reader/read-string
clojure/clojurescript@515db0a
And here we can see that
cljs.reader
, usescljs.tools.reader.edn
. But looks like thatcljs.tools.reader.edn
is a "raw primitive", that do not have the default data readers, like UUID and INST.https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/reader.cljs#L162