Welcome! Please see the About page for a little more info on how this works.

0 votes
in Syntax and reader by

The reader page at http://clojure.org/reader states that symbols (and keywords) cannot start with a number and the regex used in LispReader (and EdnReader) also has this intention. CLJ-1252 addressed this by fixing the broken reader regex to match the spec. However, that broke some existing code so we rolled back the change. There is still a disconnect here and this ticket serves to decide what to do instead.

I presume that we are effectively deciding that keywords like :5 are ok to read. If so, we should alter the regex to more accurately capture that intent - right now it allows these purely by accident due to backtracking. A secondary question is whether the Clojure and EDN reader spec should also explicitly allow these as valid. My preference would be to have the reader and the spec match, so I would lobby to loosen the reader spec.

Related ticket: CLJ-1527

6 Answers

0 votes
by

Comment made by: bronsa

what about keywords like :1/1 or :1/a? Clojure currently accepts the latter but not the former.

0 votes
by

Comment made by: favila

There's more discussion of this problem (and symbol/keyword parsing in general) in the context of cljs.reader at CLJS-677.

0 votes
by

Comment made by: jafingerhut

Francis, can you double-check that ticket number? The one you mention (CLJS-667) doesn't seem to have any discussion of this problem.

0 votes
by

Comment made by: favila

Sincere apologies, it's CLJS-677. (Original post corrected too.)

0 votes
by

Comment made by: bronsa

From a discussion in #clojure, it emerged that while :foo/1 is currently not allowed, ::1 is.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1286 (reported by alexmiller)
...