You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
According to documentation of ceylon.language.Comparison, the <=> operator (compare method) must return equal if and only if the == (equals method) returns true.
At first sight, it is doubtful that the implementation of the equals method of class Period is correct, because semantically it should make no difference how a period is represented, only how long it takes. This is a bit difficult to decide, as explained in the documentation of the normalized method.
But, presumably, the equals method should also normalize its two operands before comparing the fields.
The text was updated successfully, but these errors were encountered:
I think it was a conscious decision at the time not to normalize equals() -- the reasoning at the time was that equals() is (and hash) are very likely to be called quite often in context of collections and normalizing there might become expensive (doubly so considering that common optimization in any comparison operation is first to compare hash and then if hash code matches, consult equals).
But if the language contract says that <=> should return equal if and only if the objects == operator returns true, then I guess, my objections are all moot and this should be fixed.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
According to documentation of
ceylon.language.Comparison
, the<=>
operator (compare
method) must returnequal
if and only if the==
(equals
method) returnstrue
.At first sight, it is doubtful that the implementation of the
equals
method of classPeriod
is correct, because semantically it should make no difference how a period is represented, only how long it takes. This is a bit difficult to decide, as explained in the documentation of thenormalized
method.But, presumably, the
equals
method should also normalize its two operands before comparing the fields.The text was updated successfully, but these errors were encountered: