At the moment an origin of feature is_equal
is class ANY
, not COMPARABLE
. Class COMPARABLE
redefines the feature and adds a postcondition trichotomy
that specifies properties of equality in terms of inequality (or, in terms of a query is_less
to be more precise). So to understand what's going on, let's look at the origin.
Class ANY
has an invariant
reflexive_equality: standard_is_equal (Current)
At the same time feature is_equal
has a postcondition
consistent: standard_is_equal (other) implies Result
Combining the two (even without knowing what is standard_is_equal
) we can derive a new invariant
new_reflexive_equality: is_equal (Current)
that should be valid for every object. So as soon as o
in the expression yields the same object all the time (e.g. if it is a variable, and not a function that returns different objects at every call), o.is_equal (o)
should always produce True
. Of course, one can try to redefine is_equal
to return False
, but this would break the contract of the feature.
In real life the comparison is usually o1.is_equal (o2)
that can be True
or False
depending on values of o1
and o2
.