Why does the Clojure reader get confused with keywords containing colons? -
from reader docs:
keywords symbols, except:
they can , must begin colon, e.g. :fred.
they cannot contain '.' or name classes.
a keyword begins 2 colons resolved in current namespace
and
a symbol can contain 1 or more non-repeating ':'s.
so looks docs should explicitly allow :my:keyword keyword.
this works in repl:
user=> {:my:keyword 1} {:my:keyword 1} and works:
user=> {:mykeyword #_=> 1} {:mykeyword 1} and works
=> (clojure.edn/read-string (pr-str {:my:keyword 1})) {:my:keyword 1} but doesn't:
user=> { #_=> :my:keyword runtimeexception eof while reading, starting @ line 1 clojure.lang.util.runtimeexception (util.java:221) i can't put newline in middle of hashmap literal following keyword containing colon.
i can other keywords. works ok.
user=> { #_=> :one #_=> 1 #_=> } {:one 1} why? quirk of reader? afaict :my:keyword syntactically valid keyword. should worried other inconsistencies?
i'm using
repl-y 0.3.5, nrepl 0.2.6 clojure 1.6.0
as last example stands, haven't completed map, expect throw exception value :my:keyword is. works me.
{ :my:keyword 1 } => {:my:keyword 1}
Comments
Post a Comment