1

From the reader docs:

Keywords are like symbols, except:

They can and must begin with a colon, e.g. :fred.

They cannot contain '.' or name classes.

A keyword that begins with two colons is resolved in the current namespace

and

A symbol can contain one or more non-repeating ':'s.

So it looks like the docs should explicitly allow :my:keyword as a keyword.

This works in my REPL:

user=> {:my:keyword 1}
{:my:keyword 1}

and this works:

user=> {:mykeyword
  #_=> 1}
{:mykeyword 1}

and even this works

=> (clojure.edn/read-string (pr-str {:my:keyword 1}))
{:my:keyword 1}

But this doesn't:

user=> {
  #_=> :my:keyword

RuntimeException EOF while reading, starting at line 1
clojure.lang.Util.runtimeException (Util.java:221)

I can't put a newline in the middle of a hashmap literal immediately following a keyword containing a colon.

I can do this for other keywords. This works OK.

user=> {
  #_=> :one
  #_=> 1
  #_=> }
{:one 1}

Why? Is this just a quirk of the reader? AFAICT :my:keyword is a syntactically valid keyword. Should I be worried about other inconsistencies?

I'm using

REPL-y 0.3.5,
nREPL 0.2.6
Clojure 1.6.0
Joe
  • 46,419
  • 33
  • 155
  • 245
  • might help to know, what *your* repl there is. works fine with e.g. `java -cp clojure-1.7.0-RC1.jar clojure.main`. i get the same error with a lein repl (1.6) – cfrick Jun 15 '15 at 09:41

1 Answers1

0

As your last example stands, you haven't completed the map, so I would expect it to throw an exception with any value where :my:keyword is. This works for me.

{
 :my:keyword 1
 }
=> {:my:keyword 1}
Daniel Compton
  • 13,878
  • 4
  • 40
  • 60
  • My REPL doesn't meet your expectation, see most recent edit. Which version are you using? – Joe Jun 16 '15 at 08:52
  • Your example in the question doesn't close the map, can you check again with map } closed? – Daniel Compton Jun 16 '15 at 17:51
  • Sorry I don't understand. Do you mean the example I'm having trouble with? In this this example the exception is thrown before I can close the map, and that's my problem. – Joe Jun 17 '15 at 09:39