https://go.googlesource.com/proposal/+/refs/heads/master/des...
https://go.googlesource.com/proposal/+/refs/heads/master/des...
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.
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”.
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.
The `strings.Compare`[1] function is used to establish ordering, in the spec sense. You'd think they would name it "Order".
Similarly, the popular go-cmp[2] library provides `Equal` for equality, instead of `Compare`.
[1]: https://godoc.org/strings#Compare [2]: https://github.com/google/go-cmp
I can't find the actual code review for this. It seems to be hidden/private still?
This was the previous code review: https://go-review.googlesource.com/c/go/+/187317
The comment at the end is where I got the link to the new branch, but as an outsider, I don't have any good way to ask where the new code review is, so I'm leaving this comment here in hopes that a googler will see it and point me in the right direction.
Based on a link that's on the new branch's page, it might be CL 771577, but it says I don't have permission to view it, so I'm not sure.
The dev.go2go branch will not be merged into the main Go development tree. The branch exists mainly to support the translation tool, which is for experimenting with. Any work that flows into the main Go development will go through the code review process as usual.