clojure-dev

mfikes 2022-12-12T00:00:06.356429Z

Perhaps this is also undefined behavior:

Clojure 1.11.1
user=> (nthnext (seq "abc") -1)
(\a \b \c)
vs.
Clojure 1.12.0-alpha1
user=> (nthnext (seq "abc") -1)
Error printing return value (StringIndexOutOfBoundsException) at java.lang.String/charAt (String.java:658).
String index out of range: -1

Alex Miller (Clojure team) 2022-12-12T00:06:03.905019Z

what do you think that could even mean

Alex Miller (Clojure team) 2022-12-12T00:06:21.484209Z

(so yes, that seems undefined to me)

๐Ÿ‘ 1
Alex Miller (Clojure team) 2022-12-12T00:06:48.868759Z

I actually have a ticket about nthnext though for other circumstances

Alex Miller (Clojure team) 2022-12-12T00:07:17.475859Z

or rather nthrest

Alex Miller (Clojure team) 2022-12-12T00:07:31.465079Z

https://clojure.atlassian.net/browse/CLJ-2717

mfikes 2022-12-12T00:08:45.954829Z

Some of these I'm finding using Coal Mine (https://github.com/mfikes/coal-mine) which usually reflects new users getting lucky with some undefined behavior, and only rarely catches regressions in core functions as they evolve.

๐Ÿ‘ 1
mfikes 2022-12-12T00:21:13.052459Z

The way I'd argue nthnext makes no sense for negative arguments is that acts like a facility for applying next n times.

Alex Miller (Clojure team) 2022-12-12T02:34:05.966689Z

yes

2022-12-12T20:44:29.320089Z

My apologies if this is not the right channel for this request: Would it be possible to get a version of the install-clojure script (referenced https://clojure.org/guides/install_clojure as linux-install-1.11.1.1200.sh) that downloads a "latest" version automatically, so I don't have to go to the website and download/chmod/execute the latest version of the script?

seancorfield 2022-12-12T20:54:19.192649Z

You could pull this file to get the current stable version: https://github.com/clojure/brew-install/blob/1.11.1/VERSION -- you need the branch version in there to ensure you're not going to suddenly get a different version of Clojure as the default.

2022-12-12T20:54:44.485579Z

Oh that's cool

lispyclouds 2022-12-12T20:59:39.379549Z

https://download.clojure.org/install/linux-install.sh should work as well i think? ive been using it for a while now

โ˜๏ธ 1
seancorfield 2022-12-12T21:00:36.702729Z

Oh, totally forgot about that! Thank you!

borkdude 2022-12-12T21:01:26.471239Z

and there is also https://download.clojure.org/install/posix-install.sh for cross-platform *nix (mac + linux)

2022-12-12T21:02:41.964939Z

oh that's great. Maybe the site should be updated to highlight it?

2022-12-12T20:47:08.417139Z

My situation is that my company uses clojure from within docker, specifically leiningen, and it makes certain aspects of development much harder than necessary. I'm hoping to 1) move us to only putting our database/etc in docker while leaving clojure local, and then 2) move us to deps.edn from leiningen. The first hurdle of 1) is being able to say to the entire team: "run this script to install clojure", and then whenever there's a new release, I can ping the team and say "execute the same script you have on your machine to update automatically", instead of everyone having to perform the "download and chmod and execute" trio of steps

mfikes 2022-12-12T21:49:30.417199Z

Is dropping negative numbers undefined? The reason I ask is that the IDrop interface chooses to mention this case (`If n is <= 0, return this.`), various bits of code is checking for this, etc. But the behavior goes sideways with (drop -1 {:a 1}).

Alex Miller (Clojure team) 2022-12-12T21:55:00.537999Z

Thereโ€™s a fix in master around this I think

mfikes 2022-12-12T21:56:16.248639Z

The thinking is that drop with a negative argument would behave much like (drop 0 coll) I suppose.

Alex Miller (Clojure team) 2022-12-12T21:56:54.392519Z

Iโ€™d still say dropping a negative number has no semantic meaning :)

mfikes 2022-12-12T21:57:14.202559Z

One odd twist is that (drop -1 [1 2 3]) returns the vector where (drop 0 [1 2 3]) returns what looks like a list / seq

mfikes 2022-12-12T21:58:08.728299Z

Yeah, I was leaning towards "it's undefined", but the IDrop stuff surrounding <= 0 made me question my thinking.

2022-12-12T21:58:22.020059Z

Should it throw if given a negative number?

mfikes 2022-12-12T21:58:55.477429Z

Well, it is OK if undefined behavior doesn't result in a throw... that precedent is well established.

๐Ÿ‘ 1
mfikes 2022-12-12T21:59:40.167819Z

(Sometimes the desired checks catching undefined behavior are too expensive.)

mfikes 2022-12-12T22:03:52.550649Z

Currently the ClojureScript port is doing what some might argue drop ing negative means : Undropping something

cljs.user=> (drop -3 {:a 1, :b 2})
([nil nil] [nil nil] [nil nil] [:a 1] [:b 2])

mfikes 2022-12-12T22:04:44.923219Z

If undefined, will leave that alone. Clojure 12 alpha derails in this case. Either is OK for undefined.