This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-20
Channels
- # ai (1)
- # announcements (4)
- # babashka (61)
- # babashka-sci-dev (14)
- # biff (15)
- # calva (34)
- # clj-kondo (43)
- # clj-on-windows (1)
- # clojure (123)
- # clojure-europe (31)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-uk (4)
- # clojurescript (12)
- # code-reviews (2)
- # community-development (9)
- # core-async (3)
- # datahike (4)
- # datomic (61)
- # events (1)
- # graphql (3)
- # hyperfiddle (155)
- # introduce-yourself (1)
- # lsp (64)
- # malli (10)
- # pathom (10)
- # reagent (5)
- # reitit (6)
- # shadow-cljs (2)
- # tools-build (2)
- # vim (8)
- # xtdb (3)
Do you have that many private vars that you need to suppress a whole lot of them? :)
I use some general patterns for private functions to later generate public functions
The way I usually solve this is move those to an foo.internal
namespace and make them public
anyway, I think that every linter which can have :exclude
could have :exclude-patterns
as well, what do you think?
@U1EP3BZ3Q Note that you can also disable the unused-private-var linter in one specific namespace only
Yes, I know it. I usually prefer to narrow exclusion as much as possible. I solved this particular case by making these functions public.
Another question today, amap
warns about unused binding ret
or any used symbol (there was an issue about throwing the error which was fixed). Is it ok and should I change it to _ret
for example?
The example from ClojureDocs (https://clojuredocs.org/clojure.core/amap)
(def an-array (int-array 25000 (int 0)))
(time (amap ^ints an-array
idx
ret
(+ (int 1)
(aget ^ints an-array idx))))
ret
is internal name used by amap
which is a macro. It expands as:
(let*
[a__6552__auto__
an-array
l__6553__auto__
(alength a__6552__auto__)
ret
(aclone a__6552__auto__)]
(loop*
[idx 0]
(if (< idx l__6553__auto__)
(do
(aset ret idx (+ (int 1) (aget an-array idx)))
(recur (unchecked-inc idx)))
ret)))
It doesn't. But this is stated in documentation >
Maps an expression across an array a, using an index named idx, and
> return value named ret, initialized to a clone of a, then setting
> each element of ret to the evaluation of expr, returning the new
> array ret.
it raises the question: is there ever a situation when someone does want to have a warning about that being unused? seems unlikely right
Seem unlikely I think. It's kind of pattern introduced by authors and documented as "use ret"
Without knowing the internals, most people - probably - will use ret
because it's stated in the doc and clojuredocs examples. I agree that maybe there is someone who will complain about switching off this warning, who knows... Anyway, leaving the issue.
it feels a bit arbitrary to make an exception just for amap
- I think most clj-kondo users will know that when you're not referring to ret
, they can underscore it