clojure

2025-11-01T18:31:39.899809Z

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
Alex Miller (Clojure team) 2025-11-01T18:40:19.372579Z

You can vote for it here https://ask.clojure.org/index.php/2769/adds-docstring-support-to-defonce?show=2769#q2769

πŸ‘πŸ½ 1
borkdude 2025-11-01T19:03:47.970579Z

@folcon you can still do this:

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

2025-11-01T20:19:33.429319Z

Ahh, thanks @borkdude!

borkdude 2025-11-01T20:21:37.523199Z

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

seancorfield 2025-11-01T21:03:38.004059Z

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.

borkdude 2025-11-01T21:26:53.673429Z

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
Ryan Tate 2025-11-01T21:10:05.399179Z

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 πŸ™

2025-11-01T21:34:28.574099Z

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

jyn 2025-11-01T23:48:16.239669Z

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

mal 2025-11-01T01:50:15.579319Z

https://news.ycombinator.com/item?id=45767725 immutable talk 🍿

2025-11-01T01:54:02.331919Z

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