> Maybe collections of values should be different from collections of references. The sensible use cases for the two are quite different.
I think all existing code disagrees with that. There has been great value derived from being able to abstract over element types.
What you are proposing would double the required number of collection classes and all of its traits, because it would require separate ones for Collection[E <: AnyRef] and for Collection[E <: AnyRef].
There is literally no reason for introducing this complexity. Go has demonstrated how poorly this idea has worked out in practice.
Additionally, this approach would make it nearly impossible to migrate reference types to value types, because it would break all users of the code.
> Meh, just allow NaN to compare equal to itself. Equality is supposed to be reflexive.
That's a complete non-option. You might not like the IEEEs definition of equality, but this is what it is.
Messing with it would break all existing code using floating point numbers.
> Unboxed primitives don't have identity, only value equality.
Their identity is the bits they consist of, just like identity on references is the bits of the reference.
> They align well with what's being proposed.
What is being proposed?
> We could build the distinction into the language, so for every type you define you explicitly choose whether it's value or reference.
We already have that: AnyRef and AnyVal.
> Scala's already halfway there with the class/case class distinction.
That doesn't make any sense. The case keyword is basically just a compiler built-in macro to generate some code. It is already doing way to much, and overloading it with even more semantics is not the way to go.
> Disagree; comparison is so fundamental to most types that it's worth privileging. Using the wrong kind of comparison is a very common source of bugs.
What I'm proposing improves the consistency across value and reference types so that it's always obvious which kind of comparison happens:
- identity: Low-level comparison of the bits at hand. Built into the JVM and not overridable.
- equality: High-level comparison defined by the author of the type.