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: -1what do you think that could even mean
(so yes, that seems undefined to me)
I actually have a ticket about nthnext though for other circumstances
or rather nthrest
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.
The way I'd argue nthnext makes no sense for negative arguments is that acts like a facility for applying next n times.
yes
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?
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.
Oh that's cool
https://download.clojure.org/install/linux-install.sh should work as well i think? ive been using it for a while now
Oh, totally forgot about that! Thank you!
and there is also https://download.clojure.org/install/posix-install.sh for cross-platform *nix (mac + linux)
oh that's great. Maybe the site should be updated to highlight it?
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}).
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.
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.
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.
(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.