ClojureScript

cljs.reader support for namespaced map literal

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Clojure 1.9 extends support for namespaced maps and cljs.reader needs to be able to read them.

#:example{:key "value"} currently results in a Could not find tag parser for :example in ... error.

Activity

Hide
Thomas Heller added a comment -

I wanted to start implementing this and started looking at the "spec" [1]. It mentions support for #:: and #::alias, but since cljs.reader does not have access to aliases (or the current ns) I do not know how to proceed. Should it just throw then encountering #:: since it isn't really all that useful in a EDN context?

http://dev.clojure.org/jira/browse/CLJ-1910

Show
Thomas Heller added a comment - I wanted to start implementing this and started looking at the "spec" [1]. It mentions support for #:: and #::alias, but since cljs.reader does not have access to aliases (or the current ns) I do not know how to proceed. Should it just throw then encountering #:: since it isn't really all that useful in a EDN context? http://dev.clojure.org/jira/browse/CLJ-1910
Hide
David Nolen added a comment -

What does the Clojure EDN reader do here?

Show
David Nolen added a comment - What does the Clojure EDN reader do here?
Hide
Linus Ericsson added a comment -

The clojure.edn-reader seems to catch that it doesn't have a default namespace, nor any aliases.

user> (clojure.edn/read-string "#:a {:b 1}")
{:a/b 1}

user> (clojure.edn/read-string "#::a {:b 1}")
RuntimeException Namespaced map must specify a valid namespace: :a  clojure.lang.EdnReader$NamespaceMapReader.invoke (EdnReader.java:494)

user> (clojure.edn/read-string "#:: {:b 1}")
RuntimeException Invalid token: :  clojure.lang.Util.runtimeException (Util.java:221)

This seems to be sane defaults also for cljs.reader.

Also see the commit adding namespaces maps in clojure

Show
Linus Ericsson added a comment - The clojure.edn-reader seems to catch that it doesn't have a default namespace, nor any aliases.
user> (clojure.edn/read-string "#:a {:b 1}")
{:a/b 1}

user> (clojure.edn/read-string "#::a {:b 1}")
RuntimeException Namespaced map must specify a valid namespace: :a  clojure.lang.EdnReader$NamespaceMapReader.invoke (EdnReader.java:494)

user> (clojure.edn/read-string "#:: {:b 1}")
RuntimeException Invalid token: :  clojure.lang.Util.runtimeException (Util.java:221)
This seems to be sane defaults also for cljs.reader. Also see the commit adding namespaces maps in clojure
Hide
David Nolen added a comment -
Show
David Nolen added a comment - related CLJS-1800, CLJS-2059
Hide
António Nuno Monteiro added a comment -
Show
António Nuno Monteiro added a comment - this will be fixed by https://github.com/clojure/clojurescript/pull/69 (CLJS-1800)
Hide
David Nolen added a comment -
Show
David Nolen added a comment - fixed https://dev.clojure.org/jira/browse/CLJS-1800

People

Vote (4)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: