“A type parameter with the comparable constraint accepts as a type argument any comparable type. It permits the use of == and != with values of that type parameter”
I think that’s an unfortunate choice. Quite a few other languages use the term equatable for that, and have comparable for types that have =, ≤ and similar defined. Using comparable here closes the door for adding that later.
I also find it unfortunate that they chose
type SignedInteger interface {
type int, int8, int16, int32, int64
}
as that means other libraries cannot extend the set of types satisfying the constraint.
One couldn’t, for example, have one’s biginteger class reuse a generic gcd or lcm function.
Languages have been known to use “Ordered”, “Orderable”, or “Ord” for what you’re calling “comparable”. Rust and Haskell are both languages that fit this criteria.
The design draft refers to “constraints.Ordered”, so they’re definitely thinking about having both “comparable” and “constraints.Ordered”. Although, for consistency with “comparable”, I think it should be called “constraints.Orderable”.
Sure, but as someone else already pointed out, “comparable” is an established Go term that refers to “==“ and “!=“ only, and “ordered” refers to the other comparison operators.
My point was that “comparable” is not universally used in place of the “Ordered” term that the Go team is using, as you were seemingly implying. Ordered is a perfectly fine term for it.
You said:
> Using comparable here closes the door for adding that later.
But the door is not closed in any way. It’s just called “constraints.Ordered”, which is perfectly reasonable.
In my opinion, ordered or orderable is a better name than comparable for types implementing (<=). It evokes more of a "totally ordered" vibe than just saying "comparable", which is what we actually want in these types (in order to sort them and so on).
I think that’s an unfortunate choice. Quite a few other languages use the term equatable for that, and have comparable for types that have =, ≤ and similar defined. Using comparable here closes the door for adding that later.
I also find it unfortunate that they chose
as that means other libraries cannot extend the set of types satisfying the constraint.One couldn’t, for example, have one’s biginteger class reuse a generic gcd or lcm function.