Next section: Equality Comparisons
5. ComparisonsDylan provides an identity function, as well as a group of equality and magnitude comparison functions that can be extended for user classes. The methods ~=, >, <=, and >= are defined in terms of = and <. By extending the behavior of = and <, programs can extend the behavior of the other methods.
For the protocol to work, all methods on = and < must preserve the following properties:
- If (a == b), then (a = b).
- If (a < b) and (b < c), then (a < c).
- If (a = b) and (b = c), then (a = c).
- Exactly one of: (a < b), (a = b), (b < a) always holds
- (on the assumption that these two operations are defined for the objects in question).[ 12,13]