Fork me on GitHub

So when folks refer to Henry Baker's 'egal' paper as inspiration for Clojure's definition of clojure.core/=, I definitely get that for numbers, strings, characters, immutable collections, and references, clojure.core/= is 99% similar to Baker's 'egal'. But clojure.core/= also returns true for all kinds of pairs of mutable Java objects, which Baker's egal would return false for, wouldn't it?


you could say it is like egal for the types it knows about(which are immutable), and instead of using pointer equality for other types, it uses java's .equal, which is by default pointer equality


Yes, which seems like kind of an odd mix when likening it to Baker's egal. I understand that it can be convenient for clojure.core/= to use Java's .equal whenever a "non-Clojure type" is involved, but ... just not egal at all in those cases.

Alex Miller (Clojure team)01:05:06

The egal parts are entirely focused on Clojure data structures. Also, Clojure wants to have good (read: useful) interop with the host, which means building on Java equals. Don’t over think it.


I reserve the right to over think it 🙂 But I won't over discuss my over thinking here if I can possibly avoid it. I'm becoming convinced that different people mean different things when they say "referential transparency", and reading Henry Baker's egal paper again is confusing me more when I try to understand most of what he says -- I think partly because discussing multiple possibly meanings for equality almost means you have to qualify every statement you make with "which definition of equals am I assuming for this sentence".


Surprised (positively) by this considering

user=> (clojure-version)
user=> (let [[h & r :as s] (sorted-set 12 14)] r)
user=> (clojure-version)
user=> (let [[h & r :as s] (sorted-set 12 14)] r)
UnsupportedOperationException nth


it's a case of GIGO after a performance optimization in sequential destructuring with rest


user=> (let [[a b] (sorted-set 1 2)])
UnsupportedOperationException nth not supported on this type: PersistentTreeSet  clojure.lang.RT.nthFrom (