Dylan 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 binary= and binary<. By extending the behavior of binary= and binary<, programs can extend the behavior of the six methods.

For the protocol to work, all methods on binary= and binary< must preserve the following properties:

- Identity:
- If (id? a b), then (binary= a b).
- Transitivity:
- If (binary< a b) and (binary< b c), then (binary< a c).
- If (binary= a b) and (binary= b c), then (binary= a c).
- Trichotomy:
- Exactly one of: (binary< a b), (binary= a b),

In addition, classes which provide their own definition of binary= should provide a definition for =hash, if instances of the class will be used as keys in = hash tables.

**See Also: Dylan Design Notes: Variadic Operators (Change)**

id? returns true ifid?>object1 object2#restobjects==>boolean[Method]

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

= returns true if every=object1 object2#restobjects==>boolean[Method]

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

= is a method, so you cant add other methods to it. To extend the protocol, define methods on binary=.

/= calls binary= on/=object1 object2==>boolean[Method]

/= is a method, so you cant add other methods to it. To extend the protocol, define methods on binary=.

binary= is called by = and other comparison predicates. Programs should not normally call this function directly.binary=[next citation]object1 object2==>boolean[Generic Function]

The predefined methods on binary= behave as follows:

- Collections are equal if they have the same keys and if the values of corresponding keys are =. Keys are considered the same if they match according to the test used by the element method of the collection. If the collections use a different test, then an error is signaled. For example, an error would be signaled when trying to compare an = hash-table with an id? hash-table. An error would not be signaled when comparing a sequence and an id? hash-table.
This implies that the collections are the same size. For sequences, this means that elements at the same position are =.

- Dotted lists are equal if the elements are equal and if the final cdrs are equal.
- Built-in numbers are compared by mathematical value.
- Other objects are compared with id?.

returns a hash-code for=hash=hashobject==>integer[Generic Function]

The rule is that if two objects are =, then they must generate the same hash code when passed to =hash.

The value returned by =hash must be a integer.

**See Also: Dylan Design Notes: Variadic Operators (Change)**

< compares the<object1 object2#restobjects==>boolean[Method]

< is a method, so you cannot add other methods to it. To extend the protocol, define methods on binary<.

> compares the>object1 object2#restobjects==>boolean[Method]

> is a method, so you cannot add other methods to it. To extend the protocol, define methods on binary<.

<= compares the<=object1 object2#restobjects==>boolean[Method]

<= is a method, so you cannot add other methods to it. To extend the protocol, define methods on binary<.

>= compares the>=>=object1 object2#restobjects==>boolean[Method]

>= is a method, so you cannot add other methods to it. To extend the protocol, define methods on binary<.

The predefined methods on binary< behave as follows:

- Built-in real numbers are compared by mathematical value.
- Characters are compared by the ordinal value of the underlying character set. Character case is significant.
- Strings are compared lexicographically, using binary< on corresponding elements. If one string is a strict prefix of the other, the shorter string is considered the smaller one.