clojure 2025-12-17

I suspect I'm missing something obvious, but is there a particular reason why PersistentVector implements Comparable and PersistentList doesn't?

You aren't missing anything. There's an issue for it already, you can vote for it here: https://ask.clojure.org/index.php/2785/implement-comparable-in-persistentlist

1

Thanks. I guess this goes for ArraySeq too (ironically returned by sort).

Alex Miller (Clojure team) 2025-12-17T21:22:10.142319Z

It's unlikely that this is going to change, there are a lot of subtleties in comparing potentially infinite and non-indexed colls

I think they're talking about concrete lists, specifically PersistentList, and not any of the seq classes

To me that sounds even more confusing than the current behavior

the same way pop/`peek` only working with PersistentList despite any finite seq having comparable stack capabilities personally confuses me to no end

🤔 1

@doppiaelle1999 I do not see an Ask about pop/peek for sequences... Aren't they the same as rest & first? Which goes to show either you don't need them, or they wouldn't be hard to provide? Anyway, if you carp here about something so interesting, you really must donate an Ask!

âž• 1

Something that only occurred to me after a night of sleep is that such a change would break the guarantee of builtin stacks being finite, for a structure that is often involved in algorithms where the terminating condition is it being empty. E: rephrasing

💡 1

Most algos that use a stack also add to it so your guarantee that stack is finite at any particular point is not worth much and doesn’t guarantee that the algo doesn’t run infinite