Fork me on GitHub
#cljs-dev
<
2022-09-30
>
souenzzo21:09:59

The function clojure.edn/read-string behaves differently in clj vs cljs.

;; in clj
=> (clojure.edn/read-string "#js []")
Execution error at user/eval17 (REPL:1).
No reader function for tag js
;; in cljs
=> (clojure.edn/read-string "#js []")
#js []

thheller21:09:51

why would the clojure variant support the #js tag? you can make it read properly by providing a handler for it

souenzzo21:09:05

I think that by default, the edn/read-string function in cljs should fail too.

souenzzo21:09:13

There is many differences between clj and cljs on reading tags. Both on lisp reader and edn reader

;; clj
user=> #foo 1
Syntax error reading source at (REPL:2:0).
No reader function for tag foo
user=> (ex-data *e)
#:clojure.error{:phase :read-source}
;; cljs
cljs.user=> #foo 1
Syntax error reading source at (REPL:1).
<NO_SOURCE_FILE> [line 1, col 5] No reader function for tag foo.
1
cljs.user=> (ex-data *e)
{:type :reader-exception, :ex-kind :reader-error}
would be welcome a big summary of the differences, that could result in many issues/patches?

p-himik21:09:10

> I think that by default, the edn/read-string function in cljs should fail too. ...why? The consistency across languages that are already significantly different is not as important as having built-in platform-friendly functionality. Otherwise, you'd have to remove all js/... and js-... stuff either, and a.b access.

souenzzo21:09:00

clojure.edn/read-string isn't about clj or cljs languages. it is an edn reader.

p-himik21:09:48

Working on different platforms, in different context. Vars are also not about the language, it's a concept. And yet, they work differently in CLJ and CLJS. And JS has no characters, so \C when read will produce \C in CLJ but "C" in CLJS.

p-himik21:09:46

One thing that is a bit weird is that CLJS has #queue data reader, but CLJ does not. While both have queues.

souenzzo22:09:34

Another "residual": rationals are supported in clj edn reader