Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: Go 2: Move cmp.Ordered to builtin.orderable #62041

Closed
djordje200179 opened this issue Aug 15, 2023 · 3 comments
Closed

proposal: Go 2: Move cmp.Ordered to builtin.orderable #62041

djordje200179 opened this issue Aug 15, 2023 · 3 comments
Labels
FrozenDueToAge LanguageChange Suggested changes to the Go language Proposal v2 An incompatible library change
Milestone

Comments

@djordje200179
Copy link

Go 1.20 added comparable type constraint, Go 1.21 added cmp.Ordered type constraint.
It is probably late now, but wouldn't it be better, for the sake of consistency, to name this interface orderable, place it in builtin package, and use it in same manner as comparable interface, because both are related to comparison operators and built-in types.

Because of backwards compatibility, we could patch cmp.Ordered to be alias of orderable type constraint that would be placed besides comparable and any type constraint.

Changes:

File builtin.go:

// already existing type constraints
type any = interface{}
type comparable interface{ comparable }

type orderable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		~float32 | ~float64 |
		~string
}

File cmp.go:

type Ordered = orderable
@djordje200179 djordje200179 added LanguageChange Suggested changes to the Go language Proposal v2 An incompatible library change labels Aug 15, 2023
@gopherbot gopherbot added this to the Proposal milestone Aug 15, 2023
@seankhliao
Copy link
Member

see #59488 (comment)

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
@djordje200179
Copy link
Author

djordje200179 commented Aug 15, 2023

@seankhliao But why immediately closing it? Wouldn't it be better to let others have a discussion about this? :/

@seankhliao
Copy link
Member

this was a recent discussion, we've made the decision, and there is no new information to justify revisiting the decision at this point in time.

@golang golang locked and limited conversation to collaborators Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge LanguageChange Suggested changes to the Go language Proposal v2 An incompatible library change
Projects
None yet
Development

No branches or pull requests

3 participants