@@ -88,7 +88,9 @@ should therefore also implement [`hash`](@ref).
88
88
Similar to [`==`](@ref), except for the treatment of floating point numbers
89
89
and of missing values. `isequal` treats all floating-point `NaN` values as equal
90
90
to each other, treats `-0.0` as unequal to `0.0`, and [`missing`](@ref) as equal
91
- to `missing`. Always returns a `Bool` value.
91
+ to `missing`. Always returns a `Bool` value. It can be assumed that two values which
92
+ are `===` are also `isequal`, and that `isequal(x, y)` returns the same result as
93
+ `isequal(y, x)`.
92
94
93
95
# Implementation
94
96
The default implementation of `isequal` calls `==`, so a type that does not involve
@@ -98,8 +100,12 @@ floating-point values generally only needs to define `==`.
98
100
that `hash(x) == hash(y)`.
99
101
100
102
This typically means that types for which a custom `==` or `isequal` method exists must
101
- implement a corresponding `hash` method (and vice versa). Collections typically implement
102
- `isequal` by calling `isequal` recursively on all contents.
103
+ implement a corresponding [`hash`](@ref) method (and vice versa). Collections typically
104
+ implement `isequal` by calling `isequal` recursively on all contents.
105
+
106
+ Furthermore, `isequal` is linked with [`isless`](@ref), and they work together to
107
+ define a fixed total ordering, where only one of `isequal(x, y)`, `isless(x, y)`, or
108
+ `isless(y, x)` may be `true` (and the other two `false`).
103
109
104
110
Scalar types generally do not need to implement `isequal` separate from `==`, unless they
105
111
represent floating-point numbers amenable to a more efficient implementation than that
@@ -132,8 +138,8 @@ isequal(x::AbstractFloat, y::Real ) = (isnan(x) & isnan(y)) | signequal(
132
138
"""
133
139
isless(x, y)
134
140
135
- Test whether `x` is less than `y`, according to a fixed total order.
136
- `isless` is not defined on all pairs of values `(x, y)`. However, if it
141
+ Test whether `x` is less than `y`, according to a fixed total order (defined together with
142
+ [`isequal`](@ref)). `isless` is not defined on all pairs of values `(x, y)`. However, if it
137
143
is defined, it is expected to satisfy the following:
138
144
- If `isless(x, y)` is defined, then so is `isless(y, x)` and `isequal(x, y)`,
139
145
and exactly one of those three yields `true`.
0 commit comments