This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-28
Channels
- # announcements (19)
- # aws (4)
- # babashka (17)
- # beginners (74)
- # biff (2)
- # calva (5)
- # cider (6)
- # clerk (14)
- # clj-kondo (12)
- # cljs-dev (3)
- # clojure (40)
- # clojure-dev (26)
- # clojure-europe (28)
- # clojure-nl (1)
- # clojure-norway (39)
- # clojure-sweden (1)
- # clojure-uk (4)
- # conjure (2)
- # docker (35)
- # emacs (24)
- # graalvm (15)
- # graphql (1)
- # gratitude (4)
- # holy-lambda (2)
- # hyperfiddle (8)
- # introduce-yourself (3)
- # jobs (3)
- # nrepl (2)
- # off-topic (9)
- # pedestal (8)
- # reitit (5)
- # releases (3)
- # remote-jobs (3)
- # yamlscript (1)
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
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.
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
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 :)
ah here we go, here's a jira ticket from 2011 about dots in keywords https://clojure.atlassian.net/browse/CLJ-889
(and associated Ask for voting: https://ask.clojure.org/index.php/2808/specifically-allow-inside-keywords)
Updated docs to remove "They cannot contain '.' in the name part, or name classes." for keywords

yooooooooooooooo
Cool, thanks Alex