This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-30
Channels
- # adventofcode (95)
- # announcements (17)
- # babashka (28)
- # beginners (107)
- # calva (34)
- # clj-kondo (7)
- # cljs-dev (20)
- # cljsrn (1)
- # clojure (95)
- # clojure-europe (41)
- # clojure-italy (3)
- # clojure-nl (5)
- # clojure-spec (7)
- # clojure-uk (4)
- # clojurescript (77)
- # cursive (7)
- # data-science (1)
- # datalog (4)
- # datomic (12)
- # events (3)
- # fulcro (32)
- # graalvm (2)
- # hugsql (19)
- # introduce-yourself (4)
- # jobs (2)
- # lsp (20)
- # membrane-term (19)
- # numerical-computing (1)
- # off-topic (8)
- # pathom (3)
- # polylith (17)
- # portal (42)
- # re-frame (7)
- # reagent (32)
- # remote-jobs (1)
- # shadow-cljs (86)
- # spacemacs (3)
- # tools-deps (52)
- # uncomplicate (1)
- # xtdb (23)
an idea, could linter warn about using case with Java enums like
(let [x java.util.concurrent.TimeUnit/SECONDS]
(case x
java.util.concurrent.TimeUnit/SECONDS "secs"
java.util.concurrent.TimeUnit/MINUTES "mins"))
^ will cause "No matching clause" at runtime as case works with compile time literals... idk if this would be annoying when you actually do want to compare against symbolsI'd usually use keywords instead of symbols, but for me I'd say if the symbol matches an enum pattern some.Class/ENUM_VAL
but that would perhaps be too opinionated as a general rule
would a type hint be usable here?
(let [^java.util.concurrent.TimeUnit x java.util.concurrent.TimeUnit/SECONDS] (case x …))
would then carry the “enum type” on x
it’s quite ugly lol but maybe clj-kondo could use it?