In a thread in #beginners, @daveliepmann mentioned that it's technically illegal for keywords to contain periods in the name part. I thought this was wrong but looked it up in the https://clojure.org/reference/reader#_literals and it seems this is correct. Is this another issue with a broken reader regex and undefined behavior, now governed by Hyrum's Law? Or was the stance on periods in keywords relaxed at some point? I ask because a large part of https://github.com/seancorfield/honeysql/tree/v1's dsl is built around using the period as the separator for sql tables and columns, and I'd prefer to not rely on undefined behavior in our app UPDATE: the restriction has been removed from the reference documentation
Updated docs to remove "They cannot contain '.' in the name part, or name classes." for keywords
yooooooooooooooo
Cool, thanks Alex
Given Clojureโs record of backward compatibility donโt worry about it. I guess this line is very very old. The EDN spec doesnโt mention it https://github.com/edn-format/edn
that's true, but as recently as 2018 alex updated the text to "allow" it in the namespace portion: https://github.com/clojure/clojure-site/commit/5481163d24491ec2ebc5863bc2d0876d36aacc5a
Weird. This has already been abused in 2018. Iโm now eager to hear an official position.
If this was enforced it would break all hiccup-style libs for a start.
Yeah, it seems to me like the cat's out of the bag and it would be wise to change the docs to allow it, but I don't know the reasons for continuing to discourage it.
FWIW the major reason I noticed was that in the original thread it was a leading period, which jumped out at me because keyword rules are basically symbol rules and symbols with a leading period are reserved by Clojure.
it is legal to use . in the name part to designate a fully-qualified class name, so the regex must allow it. because the reader does not know whether it is a class, this can't be a reader error
So :div.hero is somehow illegal?
Sure, the regex allows it. But matchSymbol could be written to throw an error if a keyword's name portion contains a period.
so the spec is saying that you should not do this. I'm talking about symbols so far. this is already problematic in many ways:
user=> (def a.b.c 5)
#'user/a.b.c
user=> a.b.c
Syntax error (ClassNotFoundException) compiling at (REPL:0:0).moving to keywords, they are generally "like symbols", so the question is whether this line of the symbol spec is also "like symbols" for keywords
afaik there is nothing interpreting the name parts of keywords as classes so it seems likely to me that this operates as expected now. generally I expect to see . in the namespace part, not the name part of symbolic identifiers but I guess it is somewhat ambiguous in this case (similar ambiguity we have with leading numbers)
Right, I agree about symbols and their particular needs
given the presumed prevalence of this due to hiccup, honeysql, etc, seems unlikely that it could be disallowed at this point if we wanted to
Given such prevalence, what's the reasoning for not allowing it explicitly?
I didn't give a reasoning for that :)
lol I know, which is why I asked
I don't have a reason, but I don't just change things willy-nilly on the reference pages :)
that is, would need to double-check with Rich
ah here we go, here's a jira ticket from 2011 about dots in keywords https://clojure.atlassian.net/browse/CLJ-889
that's useful thx
(and associated Ask for voting: https://ask.clojure.org/index.php/2808/specifically-allow-inside-keywords)