This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-28
Channels
- # announcements (5)
- # babashka (7)
- # beginners (101)
- # biff (9)
- # calva (46)
- # cider (6)
- # clj-yaml (2)
- # cljsrn (13)
- # clojure (11)
- # clojure-europe (43)
- # clojure-nl (13)
- # clojure-norway (22)
- # clojurescript (20)
- # conjure (1)
- # cursive (7)
- # data-science (2)
- # datomic (26)
- # emacs (38)
- # graphql (27)
- # gratitude (5)
- # hoplon (8)
- # hugsql (22)
- # humbleui (2)
- # hyperfiddle (6)
- # introduce-yourself (8)
- # joyride (3)
- # lsp (79)
- # malli (6)
- # nbb (67)
- # portal (16)
- # rdf (27)
- # reagent (42)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (36)
- # test-check (17)
- # tools-deps (1)
- # xtdb (15)
If I have things right, docstrings should come before the arguments
(defn foo
;; my docstring
[]
(+ 1 1))
For whatever reason I have this desire to put them after the arguments
(defn foo []
;; my docstring
(+ 1 1))
Maybe it’s just that I’m used to scanning for first lines that give me the function name and the arguments all on one line. My question is whether docstrings have to be in the first position (before the arguments, if I understand correctly) for other things to work (cider docs, etc), or is there any flexibility here?They have to come before the arguments. If you place them afterwards, they will not be picked up. One reason is that you can define multi-arity functions like this:
(defn foo
"Description of foo"
([] (println "Called with 0 args"))
([a b c]
(println "Called with 3 args")))
You can define multiple arities but only one docstring, which will be attached to the var foo
in its metadata.
Well, dang. Case closed. Thanks for the answer and it now makes perfect sense.
Sometimes I toy with the idea of using:
(defn ^{:doc "The doc"}
foo [x y z]
42)
People won't like it so I refrain, but like you, I appreciate having the fn name and arguments in the same line (which relates to f(x)
math notation. Among other arguments 🙂)@U45T93RA6 thank you for weighing in! Yeah, I have no idea why the usual docstring position feels so strange… and it’s nice to know about this possibility.
I'd say the docstring, when present, breaks the rhythm between fn name and args... we say "launch missile", not "launch <random rambling> missile"
I am using toyokumo/tarayo
for smtp and com.sun.mail/javax.mail
for imap. They are located in separate sub projects and work ok on their own. The moment I start the main project I get the error jakarta.mail.Provider: Provider com.sun.mail.imap.IMAPProvider not a subtype
when I try to run something from the smtp project. I had a similar problem for the imap project, but managed to "fix" it by doing the following dependency [com.sun.mail/javax.mail :exclusions [toyokumo/tarayo]]
. I am going crazy trying to fix this problem, anyone has any ideas?
@all I am currently working on a clojure project, and using a library that's built in Scala
, Now I have function, which tries to a process a list of messages, recursively. Let's say
1. [m1,m2,m3,m4] are my mesages to be processed
2. m1 is success
3. m2 is success
m3 fails, so i use .recover
but my local variable which stores the list to be processed i.e., (rest [m3,m4])
is using the m2's data so it becomes (rest [m2,m3,m4])
Someone shed some light on this
It's a little unclear exactly what the issue is here. You're saying you have some code which processes a list, has processed several messages, and you wish to perform some action on the remaining messages after one fails? Or you wanted to return the ones that weren't successfully processed? Or what?