I'm kind of iffy on `(get "abc" 1.9)`. I feel like Clojure has always kind of went out of its way to not go to Ruby levels of implicit dynamism. Think things like: "5" * 3 => "555". Explicit > implicit has been a guiding principle in Clojure since the beginning. For that reason I think the behavior is... a little surprising, but also tend to agree I would stop short of calling it a "bug" in any meaningful sense of the word. I'm curious to see what the core maintainers decide to do about it, if anything. If I were a betting man I'd guess it will stay this way forever because existing programs may quietly (or not-so-quietly) rely on the current behavior.
Hyrum's law, anyone?
> With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.
I believe most significant/critical software (written in Clojure) would not pass a float/double as a key in the context of string object. At the same time, instead of evaluating the impact of such a change, the core team may just lean on Hyrum's law and decide to not change the behavior. It is also possible that the core team may just ignore this list.
So, while I prefer changing get's behavior to match our intuition in the context of string objects, I think it could go either way, which is not saying much :)
I'm more upset at the (get "abc" 1.9) and that "abc"[1.9] also works in Ruby, than I am that "5" * 3 results in "555". The former feels more surprising. There's an expectation that "*" must do something different to a string, so if in doubt I'd look it up. But that a float is quietly floor'ed was surprising enough to me that I've used Ruby for more than 20 years, written a compiler* for a good subset of Ruby, and still didn't realise.
Hyrum's law, anyone?
> With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.
Replies (3)
So, while I prefer changing get's behavior to match our intuition in the context of string objects, I think it could go either way, which is not saying much :)
Well, what does the specification say?