clojure 2025-11-01

I've been trying to work out why this is, but I've not got a good answer so I thought I'd ask here, why does defonce not accept an optional docstring?

Alex Miller (Clojure team) 2025-11-01T18:38:35.265339Z

No good reason. We have an old ticket about it, fixing it is surprisingly more subtle than expected

πŸ™πŸ½ 1

@folcon you can still do this:

user=> (defonce ^{:doc "dude"} foo 1)
#'user/foo
user=> (doc foo)
-------------------------
user/foo
  dude

Hmm can you evaluate that twice and see if the docstring is still there? That might be the caveat, haven’t tried

user=> (defonce ^{:doc "first"} foo "one")
#'user/foo
user=> foo
"one"
user=> (doc foo)
-------------------------
user/foo
  first
nil
user=> (defonce ^{:doc "second"} foo "two")
nil
user=> foo
"one"
user=> (doc foo)
-------------------------
user/foo
  second
nil
So the metadata is updated by invoking it again even tho' the value is not.

ok, but as long as the same expression can be evaluated multiple times, the docstring will stay in place so that's good I guess.

user=> (defonce ^{:doc "dude"} foo 1)
#'user/foo
user=> (doc foo)
-------------------------
user/foo
  dude
nil
user=> (defonce ^{:doc "dude"} foo 1)
nil
user=> (doc foo)
-------------------------
user/foo
  dude

πŸ‘πŸ» 1
πŸ‘πŸ½ 1

This is very niche, possibly not the right place, and probably talking into the wind πŸ˜…, but: The https://clojure.org/guides/install_clojure#_posix_instructions, posix-install.sh, seems to assume bash even though the shebang declares generic #!/usr/bin/sh. On SmartOS (an illumos/Solaris derviative) the local sh is Korn Shell (`ksh93`), which seems to trip over the use of local in do-install (I am guessing it tries to use the local localwhich is for mail delivery via Postfix). Changing the shebang line to be explicitly #!/usr/bin/bash fixes this and it works fine (with a --prefix). I realize smartOS isn't explicitly supported by this script, but on the other hand, since bash is listed as a prerequisite, I wonder if there is any reason to not just put bash in the shebang. Just my .02 πŸ™

I wonder if the Linux script would just work https://github.com/clojure/brew-install/blob/1.12.3/src/main/resources/clojure/install/linux-install.sh I forget if the -e option to sed is a gnu'ism

local is not technically in POSIX but basically every shell script assumes it because both ash (busybox) and dash (debian) support it

funnily enough, John's advice also good advice on clojure: don't shadow bindings πŸ˜„