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

0 votes
in Syntax and reader by

The documentation for keywords (on page http://clojure.org/reader) specifically states that '.' is not allowed as part of a keyword name; however '.' is specifically useful. For example, several web frameworks for Clojure use keywords to represent HTML elements, using CSS selector syntax (i.e., :div.important is equivalent to

).

In any case, the use of '.' is not checked by the reader and it is generally useful.

I would like to see '.' officially allowed (in the documentation). Further, I'd like to see additional details about which punctuation characters are allowed (my own web framework uses '&', '?' and '>' inside keywords for various purposes ... again, current reader implementation does not forbid this, but if a future reader will reject it, I'd like to know now).

5 Answers

0 votes
by

Comment made by: hlewisship

To clarify, Hiccup and Cascade both use keywords containing '#' and '.' Cascade goes further, using '&' (to represent HTML entities), '>', and (possibly in the future) '?'.

0 votes
by

Comment made by: devn

I think the EDN spec mitigates some of the concern, but as of yet the official clojure.org reader documentation does not reflect the language used in the description of EDN. Where does EDN stand right now? Can the description being used on the github page be pulled over to clojure.org?

References:
- https://github.com/edn-format/edn#keywords
- http://clojure.org/reader#The Reader--extensible data notation (edn)

0 votes
by

Comment made by: hlewisship

Unfortunately, the EDN specification does not mention '>'.

0 votes
by

Comment made by: vitoshka

It's worth noting that the most common prefix character '#' is allowed in keywords by the reader, but other prefix characters '`', '@' and '~' are not. None of these characters are allowed as part of symbols proper.

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