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
Un-deprecate default floating point Orderings #8612
Conversation
This is the only alternative that is acceptable in a minor version, IMO. The other two PRs intentionally break valid existing code. |
@NthPortal As @sjrd suggested I've opened a new issue scala/bug#11844. Could you update the commit message to point to it please? |
@sjrd - Actually, this is the PR that intentionally and silently breaks valid existing code, because in 2.12 (and earlier), the behavior was that of |
@Ichoran Scala 2.12.10 returned the following for min and max: scala> Array(2.0, 1.0, NaN, 3.0, 0.0, -0.0).max
res1: Double = 3.0
scala> Array(2.0, 1.0, NaN, 3.0, 0.0, -0.0).min
res2: Double = 0.0 This behavior does not match either the java.util.Collections sorting order or IEEE, since IEEE would return NaN for both. |
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.
For List#min
and List#max
returning the first and last element of the sort makes sense and it's consistent with java.util.Collections.max
.
@eed3si9n - 2.12.0's min and max aren't implemented correctly for a non-total-order. I don't advocate restoring that behavior, as it's unpredictable. It effectively deletes the list up to the last |
@Ichoran Is there a sequence that would make Scala 2.13.1 (TotalOrdering) sort differently from Scala 2.12 or IEEEOrdering? Using Assuming that's the case, the difference between Total vs IEEE comes down to the result of Continuing to go Total by default and returning the last value of the |
@eed3si9n - Both 2.13.0 and 2.12.whatever use the Java ordering, so the sorting should be identical between the two (at least in the absence of bugs). Indeed, both The question here is not about sort order. It is also not entirely about the collections max method. The issue is that you have abstracted ordering of numeric operations with Again, this is only about max/min (and to a lesser extent |
On Scala 2.13.1, |
@eed3si9n - Yes, the
one you have to use in a generic context. |
ok. That seems to be an example where 2.12.x and 2.13.1 do give different results. 2.12.10scala> import java.lang.Double.NaN
import java.lang.Double.NaN
scala> def typeclassMin[A: Ordering](a: A, aa: A): A = {
| val ord = implicitly[Ordering[A]]
| import ord._
| a min aa
| }
typeclassMin: [A](a: A, aa: A)(implicit evidence$1: Ordering[A])A
scala> typeclassMin(2.0, NaN)
res3: Double = NaN 2.13.1scala> typeclassMin(2.0, NaN)
warning: there was one deprecation warning (since 2.13.0); for details, enable `:setting -deprecation' or `:replay -deprecation'
res1: Double = 2.0
scala> { import Ordering.Double.IeeeOrdering; typeclassMin(2.0, NaN) }
res3: Double = NaN
scala> { import Ordering.Double.TotalOrdering; typeclassMin(2.0, NaN) }
res4: Double = 2.0 |
mhm. the default |
Given the discussion on scala/bug#11844, I'm no longer sure if this is the right way to go - scala/bug#11844 (comment) |
I continue to lean towards Sébastien's proposed solution (scala/bug#11844 (comment)) |
Reopened, as I believe the leading contender currently is a version of this PR that replaces the deprecation warning with an |
@NthPortal are you interested in adding the migration warning? in the next week or so? If you're too busy or just not interested, it's fine, one of us from the core team can do it |
@SethTisue If I had a good idea of what the wording should be, I'd be happy to do it; however, I don't have the capacity right now to come up with a good one. If someone provides one, I'm happy to adjust this PR to use it (and un-delete the partest; possibly rename it?). Or someone else could adjust this PR, or open a new PR. Thanks for keeping this rolling |
closing in favour of #8721 |
Fixes scala/bug#10511. One of 3 proposed solutions; the others are #8613 and #8614.