This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-19
Channels
- # aleph (8)
- # announcements (43)
- # babashka (43)
- # beginners (62)
- # calva (8)
- # cider (27)
- # clj-kondo (18)
- # cljs-dev (25)
- # cljsrn (16)
- # clojure (51)
- # clojure-europe (6)
- # clojure-nl (14)
- # clojure-spec (7)
- # clojure-uk (39)
- # clojurescript (17)
- # cursive (9)
- # datascript (12)
- # datomic (16)
- # events (1)
- # fulcro (7)
- # funcool (1)
- # graalvm (2)
- # graphql (5)
- # jobs (1)
- # juxt (6)
- # kaocha (9)
- # leiningen (11)
- # luminus (1)
- # malli (1)
- # off-topic (80)
- # other-languages (2)
- # overtone (3)
- # pedestal (5)
- # quil (1)
- # re-frame (6)
- # reagent (1)
- # reitit (4)
- # rewrite-clj (5)
- # shadow-cljs (207)
- # spacemacs (1)
- # specter (4)
- # sql (1)
- # vim (14)
- # xtdb (7)
Does clj-kondo warn when some know lazy construct is being created but not forced to be realized in the lexical scope of with-redefs
?
After more thinking, doing so would require analysis through dynamic scopes, because things outside of core can both create lazy stuff and force it to be realized (without telling us so). So maybe it is out of scope for clj-kondo. Maybe a job for a more involved static analysis tool.
@jaihindhreddy Same trouble with try
, with-open
and binding
Clj-kondo could in theory warn about (try (map ...))
because it can know about a set of functions that are lazy like map
. Maybe eastwood already has this? I'll ask in their channel.
Ah great, it's in var-info.edn
already: https://github.com/jonase/eastwood/blob/fa22247fa976d03fd37cdfbb4554d26e61b3842b/resource/var-info.edn#L373
@jaihindhreddy Feel free to post more examples here: https://github.com/borkdude/clj-kondo/issues/614
@borkdude Sorry, I had to fix another error I made (def i.s.o. defn) first... From the Clojure for the Brave and True book, chapter 6:
(ns the-divine-cheese-code.core
(:gen-class))
(require 'the-divine-cheese-code.visualization.svg)
(refer 'the-divine-cheese-code.visualization.svg)
(def heists [{:location "Cologne, Germany"
:cheese-name "Archbishop Hildebold's Cheese Pretzel"
:lat 50.95
:lng 6.97}
{:location "Zurich, Switzerland"
:cheese-name "The Standard Emmental"
:lat 47.37
:lng 8.55}
{:location "Marseille, France"
:cheese-name "Le Fromage de Cosquer"
:lat 43.30
:lng 5.37}
{:location "Zurich, Switzerland"
:cheese-name "The Lesser Emmental"
:lat 47.37
:lng 8.55}
{:location "Vatican City"
:cheese-name "The Cheese of Turin"
:lat 41.90
:lng 12.45}])
(defn -main
[& args]
(println (points heists)))
clj-kondo complains about 'points' in the prinln form.
lein run gives expected output, though.and the corresponding namespace:
(ns the-divine-cheese-code.visualization.svg)
(defn latlng->point
"Convert lat/lng map to comma-separated string"
[latlng]
(str (:lat latlng) "," (:lng latlng)))
(defn points
[locations]
(clojure.string/join " " (map latlng->point locations)))
@roger429 clj-kondo doesn't support (refer ...)
. To be honest I've never used this myself in 10 years of Clojure. Just use (require '[the-divine... :refer [points]])
(require ['the-divine-cheese-code.visualization.svg :refer [points]])
still has squiggles under points.Thank you! I'm not the eagle-eyed reader at the moment that Daniel Higginbotham assumes his readers to be:blush: