This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-23
Channels
- # announcements (1)
- # asami (2)
- # aws (15)
- # babashka (4)
- # beginners (42)
- # calva (8)
- # clj-kondo (7)
- # cljsrn (31)
- # clojure (64)
- # clojure-australia (4)
- # clojure-europe (40)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-uk (10)
- # clojured (1)
- # clojurescript (16)
- # conjure (4)
- # datomic (5)
- # defnpodcast (2)
- # events (1)
- # fulcro (61)
- # graphql (11)
- # honeysql (9)
- # jobs (3)
- # jobs-discuss (3)
- # lsp (65)
- # malli (3)
- # meander (4)
- # off-topic (5)
- # pathom (32)
- # podcasts-discuss (2)
- # polylith (2)
- # re-frame (30)
- # reitit (6)
- # remote-jobs (3)
- # ring (4)
- # shadow-cljs (19)
- # sql (28)
- # vim (1)
- # xtdb (21)
Here's a touch one: Can we use operators that are not valid clojure keywords? Postgresql has some array operators that contain @
, particularly @>
and <@
dev=> (def at> (keyword "@>"))
#'dev/at>
dev=> (def <at (keyword "<@"))
#'dev/<at
dev=> (sql/register-op! at>)
nil
dev=> (sql/register-op! <at)
nil
dev=> (sql/format {:select :* :from :foo :where [:and [at> :a :b] [<at :c :d]]})
["SELECT * FROM foo WHERE (a @> b) AND (c <@ d)"]
I do exactly this, but are the warnings on https://clojuredocs.org/clojure.core/keyword still valid?
;; keyword does not validate input strings for ns and name, and may
;; return improper keywords with undefined behavior for non-conformant
;; ns and name.
;; Warning - the following generated keywords are non-conformant and may wreak
;; serious havoc in the near/far future when least expected...
iirc undefined === "behavior can change at any time"I don't think it's a big deal here, but I see a lot of places where people e.g. take arbitrary JSON as input and decode with keyword keys, and it seems pretty scary if the result is undefined
Should I be a stickler about using string keys, or are keywords actually fine?
The core team did at one point try to tighten up what keywords the reader accepted but it broke quite a bit of code out there — so they reverted that change. I think at this point you are “safe” creating unreadable keywords via keyword
as long as you don’t actually try to read
them!.
(and, in particular, http://clojuredocs.org is not official documentation so examples and commentary are what random community members think 🙂 )