This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-24
Channels
- # aleph (5)
- # announcements (18)
- # babashka (3)
- # babashka-sci-dev (56)
- # beginners (56)
- # biff (5)
- # calva (27)
- # cider (20)
- # clj-commons (2)
- # clj-kondo (17)
- # cljsrn (18)
- # clojure (41)
- # clojure-europe (24)
- # clojure-nl (1)
- # clojure-serbia (1)
- # clojure-uk (15)
- # clojured (1)
- # clojurescript (40)
- # cursive (39)
- # datahike (2)
- # datalevin (4)
- # datascript (5)
- # emacs (23)
- # events (2)
- # figwheel-main (3)
- # inf-clojure (1)
- # instaparse (23)
- # introduce-yourself (3)
- # jobs (3)
- # jobs-discuss (13)
- # joyride (1)
- # juxt (10)
- # malli (21)
- # nbb (29)
- # off-topic (18)
- # pathom (29)
- # polylith (11)
- # project-updates (1)
- # proletarian (1)
- # rdf (2)
- # re-frame (4)
- # reitit (2)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (52)
- # tools-deps (57)
- # xtdb (32)
(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.
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
Alright. So even if I exclusively use Clojure, you'd discourage this
Here is an example from CLJS:
$ plk
ClojureScript 1.10.914
cljs.user=> :
Syntax error reading source at (<cljs repl>:1).
Invalid keyword: :.
I'm really curious what the usecase was that you had wanted to store a uri in a keyword.
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.
right, but I don't quite get why it would be more appropriate to use a keyword than a string, even in theory.
ah, right
Yes, it's exactly that @U04V15CAJ. In fact, you may be thinking of the library I'm using (https://github.com/ont-app/vocabulary) 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.