This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-26
Channels
- # aleph (9)
- # announcements (10)
- # aws (1)
- # beginners (65)
- # calva (9)
- # cider (11)
- # clj-kondo (1)
- # cljdoc (61)
- # cljsrn (6)
- # clojars (2)
- # clojure (40)
- # clojure-austin (1)
- # clojure-belgium (1)
- # clojure-europe (4)
- # clojure-finland (1)
- # clojure-france (1)
- # clojure-italy (57)
- # clojure-nl (6)
- # clojure-spec (134)
- # clojure-uk (67)
- # clojuredesign-podcast (2)
- # clojurescript (40)
- # cursive (25)
- # datascript (1)
- # datomic (8)
- # events (1)
- # figwheel-main (18)
- # fulcro (36)
- # immutant (5)
- # jobs (5)
- # joker (3)
- # kaocha (41)
- # leiningen (4)
- # luminus (4)
- # off-topic (13)
- # onyx (8)
- # pedestal (2)
- # perun (7)
- # planck (2)
- # protorepl (9)
- # re-frame (3)
- # reagent (73)
- # reitit (5)
- # shadow-cljs (186)
- # sql (4)
- # vim (1)
- # yada (2)
I have submitted a couple of PRs - if you are in a reviewing mood, feedback is MOST welcome.
clj-kondo warns about unused things, and I see quite often destructuring of keys that are not used, for example group-id and artifact-id are not used here: https://github.com/cljdoc/cljdoc/blob/d54cb58b20d2b4cb1e7c714b3637aa8b89956ce0/src/cljdoc/server/ingest.clj#L16
before I delete, was this some sort of strategy to help when walking through code with debugger or something? @martinklepsch
I recently commented on this here: https://github.com/candid82/joker/issues/240#issuecomment-508985091
I think I am too. Like you say, if it needs more describing there are specs - although they can be far away from the function you are reading.
I thought this project announced today looked interesting: https://github.com/nedap/speced.def
anyway I shall wait for @martinklepsch to opine for cljdoc.
Yeah I suppose if they aren’t used they are really a comment, so docstring would be an alternative.
actually @borkdude if the intent is documentation, although an underscore prefix might seem silly on a destructured key, it does convey the key is available but unused.
some editors give you the arg names and destructuring info as you type. when you see underscores keys that's possibly confusing
the convention of underscore = unused is wildly understood, I think people would understand… oh but editors might give confusing help… I see.
it's an interesting topic for cljdoc: destructuring as documentation, yes or no. I guess you will also see it in generated documentation?
yup: https://cljdoc.org/d/cljdoc/cljdoc/0.0.1315-c9e9a7e/api/cljdoc.server.ingest#ingest-cljdoc-edn
so then the question is: is there a way to get this information without paying the penalty of destructuring? e.g providing an arg-list, or spec
user=> (def ^{:arglists '([{:keys [:x :y :z]}])} f (fn [obj]))
#'user/f
user=> (doc f)
-------------------------
user/f
([{:keys [:x :y :z]}])
nil
cljdoc also looks at the arglists metadata
(And the code is largely based on codox)
I think specs would be a more complete/interesting data source than the destructuring and explicit declaration we can find in arglists metadata
Spec stuff really needs to be revisited. At some point I threw in the towel but maybe a different pair of eyes has different ideas
If there’s interest I would be happy to summarize my findings and some stuff that’s spread across GitHub comments
I added arglists to this discussion: https://github.com/candid82/joker/issues/240#issuecomment-515616779
@martinklepsch I started asking about this when looking specifically at cljdoc codebase… then we got into our interesting general discussion. For cljdoc codebase, am I right that, for now, unused destructured keys act as documentation and should be left in?
(or move them to arglists if they aren't used, but you still want them in the outputted docs)
@lee I have explored using them this way but haven’t come to a strong opinion on either choice. Without an explicit decision (ADR) I’d suggest to not touch code solely for formatting* sake but if we need to make that decision we can totally just reformat everything 😂 *thats kind of how I view it I guess.
unused namespaces are easy… they get deleted from code. unused destructured keys are a topic of their own.
If a linter doesn’t like this ~formatting that might be enough of a reason to make a change
well, the linter is just asking, “hey, are you sure you want to do this?” and we can answer, if we want, “thanks for the tip, we like things this way”
right now our answer for unused destructured keys is: we’re not sure, so thanks for the tip, but we’ll stick with what we are doing for now.
@martinklepsch, on the topic of formatting, I often forget to leave a space here or there in a commit, have you considered using a format checker to check for this type of thing? maybe cljfmt would work for this?
it's finally cooling down here. we had a couple of days of 37-40 degrees Celsius and at night it wouldn't cool down below 24...
Good evening Lee! 👋