Fork me on GitHub
Bart Kleijngeld06:05:57

(This is probably a beginner question, so if it's better suited for #beginners let me know.)

Invalid keyword: .      clj-kondo(syntax)
1. Why is this considered invalid? Clojure seems to handle it just fine. 2. If it's a matter of preference by the linter, then: a. Why it this a bad idea? b. If I would want to, is there a way to configure clj-kondo to be okay with this? Loving clj-kondo as essential part of my workflow, thanks!


Google for Clojure reader and go to the keyword or symbol section. There it says that they can only contain one slash to separate the namespace and name part. On the phone right now, can send the link later.

gratitude 1
Bart Kleijngeld07:05:10

Yes, I did read the documentation. You're referring to: > '/' has special meaning, it can be used once in the middle of a symbol to separate the namespace from the name Personally I'd say "only once" would've been clearer, but it seems pretty clear that you're interpretation is shared by everyone I read. Interestingly though, Clojure is perfectly fine with these keywords, which perhaps does point to my interpretation that "can be used once" doesn't imply that it cannot be used more than once. What do you think?


It might not work in ClojureScript or babashka which has a different reader implementation


In general the reader accepts more than what is specified and this may change any time, don't rely on it

Bart Kleijngeld07:05:32

Alright. So even if I exclusively use Clojure, you'd discourage this

Bart Kleijngeld07:05:55

Thanks for the quick responses and clarification!

👍 1

Here is an example from CLJS:

$ plk
ClojureScript 1.10.914
cljs.user=> :
Syntax error reading source at (<cljs repl>:1).
Invalid keyword: :.

👍 1
Joshua Suskalo15:05:52

I'm really curious what the usecase was that you had wanted to store a uri in a keyword.


I've had this use case in a job once, where we did stuff with RDF


And transit didn't complain on the front-end, but if you type this as a literal in CLJS, it crashes. The docs say it isn't supported so it's probably better keep as string.

Joshua Suskalo15:05:58

right, but I don't quite get why it would be more appropriate to use a keyword than a string, even in theory.


Some maps have these things as keys and they would be automatically converted

Bart Kleijngeld15:05:39

Yes, it's exactly that @U04V15CAJ. In fact, you may be thinking of the library I'm using ( which provides maps like that. Btw, the library provides tools I wasn't aware of which circumvents the issues. By using keyword-for , the passed in URI is escaped to the extent necessary to be found valid by the reader. This way you never run into issues besides potential loss of readability in your data.