-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ export | |
Irrational, | ||
Matrix, | ||
MergeSort, | ||
NotComparableError, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tkelman
Contributor
|
||
NTuple, | ||
Nullable, | ||
ObjectIdDict, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,15 @@ supertype(T::DataType) = T.super | |
|
||
## generic comparison ## | ||
|
||
==(x,y) = x === y | ||
|
||
isequal(x, y) = x == y | ||
=={T}(x::T, y::T) = x === y | ||
immutable NotComparableError <: Exception end | ||
const NotComparable = NotComparableError() | ||
==(x::ANY, y::ANY) = NotComparable | ||
This comment has been minimized.
Sorry, something went wrong. |
||
!(e::NotComparableError) = throw(e) | ||
# immutable NotComparableError; a; b; end | ||
# ==(x::ANY, y::ANY) = NotComparableError(x, y) | ||
|
||
isequal(x, y) = (x == y) === true | ||
This comment has been minimized.
Sorry, something went wrong.
kmsquire
Member
|
||
isequal(x::AbstractFloat, y::AbstractFloat) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) | ||
isequal(x::Real, y::AbstractFloat) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) | ||
isequal(x::AbstractFloat, y::Real ) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) | ||
|
6 comments
on commit 4533cc1
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.
I'm a bit surprised by how non-disruptive this change is in Base Julia. I rather like it.
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.
This will break some things for users of Match.jl
--at least, the assumption there is that everything is comparable. 😦
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.
As for #9381, I'm still worried about 0.0 in A
not finding -0.0. I think that's much more serious than cases involving NaN.
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.
This will break some things for users of Match.jl--at least, the assumption there is that everything is comparable.
Following up on this... suppose I want to be able to return false for things that are not comparable. What would be the best way forward? Redefine
==(x,y) = x === y
isequal(x, y) = x == y
in Match.jl?
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.
Sorry all, I've deleted this branch to reduce confusion. I wasn't actually trying to propose doing this, but was just getting an idea of the scope of #9381 (though having an idea of the Match.ji use case is helpful)
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.
should this be grouped with other exception types? I think there's also a table of them in the docs