Reading "%" with the ClojureScript reader

76 views
Skip to first unread message

Jonas Enlund

unread,
Jul 22, 2013, 12:20:44 PM7/22/13
to cloju...@googlegroups.com
Hi

According to the edn spec[1] '%' is a valid symbol and it's currently being used in datomics datalog to refer to rules. The ClojureScript reader is not able to read "%" as a symbol as shown by the following repl session:

cljs.user> (ns cljs.user (:require [cljs.reader :refer [read-string]]))
nil
cljs.user> (read-string "%")
org.mozilla.javascript.JavaScriptException: Error: Reader for % not implemented yet


The reason for the error is at[2] where '%' is explicitly called out to throw the above error (probably to leave room for future extensions?).

Given the edn spec and the fact that the symbol can be read with the Clojure reader (and the new Clojure edn reader), should we lift this restriction and allow "%" to be read by the ClojureScript reader?

If all agree I can open an issue+patch on JIRA where I remove the line at [2].

/Jonas

[1] https://github.com/edn-format/edn#symbols
[2] https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/reader.cljs#L401

David Nolen

unread,
Jul 23, 2013, 12:06:04 PM7/23/13
to cloju...@googlegroups.com
Ticket + patch welcome, thanks!



--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gary Fredericks

unread,
Jul 23, 2013, 4:29:48 PM7/23/13
to cloju...@googlegroups.com
Was the point of the error to be able to read forms like "#(%5)" correctly? E.g., on clj-jvm we have

(read-string "#(%5)") => (fn* [p1__3878# p2__3879# p3__3880# p4__3881# p5__3877#] (p5__3877#))

Would cljs have the same behavior if the error were removed? should it?

Jonas Enlund

unread,
Jul 23, 2013, 4:51:44 PM7/23/13
to cloju...@googlegroups.com
The clojurescript reader does not implement the #(...) reader macro.
Reply all
Reply to author
Forward
0 new messages