Fork me on GitHub

Perhaps this is also undefined behavior:

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

Alex Miller (Clojure team)00:12:03

what do you think that could even mean

Alex Miller (Clojure team)00:12:21

(so yes, that seems undefined to me)

👍 1
Alex Miller (Clojure team)00:12:48

I actually have a ticket about nthnext though for other circumstances


Some of these I'm finding using 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

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

Noah Bogart20:12:29

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 as 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?


You could pull this file to get the current stable 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.

Noah Bogart20:12:44

Oh that's cool

lispyclouds20:12:39 should work as well i think? ive been using it for a while now

☝️ 1

Oh, totally forgot about that! Thank you!


and there is also for cross-platform *nix (mac + linux)

Noah Bogart21:12:41

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

Noah Bogart20:12:08

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


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)21:12:00

There’s a fix in master around this I think


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

Alex Miller (Clojure team)21:12:54

I’d still say dropping a negative number has no semantic meaning :)


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


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

Noah Bogart21:12:22

Should it throw if given a negative number?


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

👍 1

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


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])


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