Previous section: 5. Comparisons

Dylan reference manual -- Equality Comparisons

Equality Comparisons

object1  ==  object2  =>  boolean	[Function]
== returns true if object1 andobject2 are identical. Otherwise, it returns false.

Objects are considered identical if they are computationally equivalent. That is, there is no way for any possible Dylan program to distinguish them.[14]

object1  = object2   =>  boolean	[Generic Function]
Programmers may define methods for = specialized on classes they define. A programmer may be required to provide a = method when defining subclasses of some predefined classes in order to fullfill the protocol of the class, as described below.

- Two collections are equal if they have identical key-test functions, they have the same keys (as determined by their key-test functions), the elements at corresponding keys are =, and neither is a dotted list.

-Two dotted lists are equal if they are the same size, corresponding elements are =, and the final tails are =.

- Numbers are equal if they have the same mathematical value.

- For objects which do not have a more specific = method, = returns the same as ==.

= is not guaranteed to return (for example, when called on circular structures or unbounded structures).

 object1  ~=  object2   =>  boolean	[Function]
~= calls = on object1 and object2. Returns true if = returns false.

~= is not a generic function, so you can't add methods to it. To extend the protocol, define methods on =.

Next section: Magnitude Comparisons