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

0 votes
in Clojure by


The pipe char | is accepted as a symbol constituent char both in clj and cljs:

user> {:one|two 'three|four}
{:one|two three|four}

cljs.user> {:one|two 'three|four}
{:one|two three|four}

though it is not mentioned as such in official sources:


Is it safe to assume it is a valid symbol constituent character since it is accepted by the reader as such?


1 Answer

+1 vote

You should not use |, it is being reserved for possible delimited names.

Specifically, something like :one|two 'three|four might in the future actually read as a single keyword with embedded space and quote.

Thanks, I got this coming up as keyword key while converting java hasmaps into keywordized clojure maps.

Would it better perhaps to have the reader throw this as an invalid char for symbols? Or is there a danger that backward compatibility could break if this char is starting to have a more elaborate meaning in a later release?
See https://clojure.org/guides/faq#unreadable_keywords for why we don't validate this. By using characters not on the reader list, you are in undefined behavior territory.