-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add an Ordering given instance for named tuples #23379
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
base: main
Are you sure you want to change the base?
Conversation
I would classify it as a bug fix, so no minor release needed. |
Er ... no? It's a new public, stable API. Our policy does not let us add this kind of thing in a patch release, since it can break source compatibility. In fact, it is quite likely to break source compatibility: users who were actively missing this may have introduced such a This does require a minor release. |
@sjrd It won't cause an ambiguity because users would have added the feature with an implicit import. And the likelihood that we introduce conflicts increases the longer we wait. |
given namedTupleOrdering: [N <: Tuple, V <: Tuple] => (ord: Ordering[V]) => Ordering[NamedTuple[N, V]]: | ||
def compare(x: NamedTuple[N, V], y: NamedTuple[N, V]): Int = | ||
ord.compare(x.toTuple, y.toTuple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but is it worth constructing this manually, when there's already a Ordering.by
helper for situations like this?
given namedTupleOrdering: [N <: Tuple, V <: Tuple] => Ordering[V] => Ordering[NamedTuple[N, V]] =
Ordering.by(_.toTuple)
Not that it makes much of a difference, but should be slightly less error prone (e.g. for sure the x
and y
won't be switched).
I think we should not add new API in patch releases, even if it seems tempting in a particular case such as this one. Adding new (non-experimental) API in patch releases is something we Simply Do Not Do. If we don't adhere to these rules then version numbers become meaningless and users are reduced to playing guessing games about what they mean. We made it all the way from 3.0.0 to 3.7.1 without doing this (at least, I don't recall that we ever made any exceptions?). Let's not start now. |
OK, let's schedule for 3.8. We should approve it now so that it's ready to get in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT
No description provided.