12 The Built-In Functions

`min`

and `max`

are defined in terms of == or = and <. By extending the behavior of = and <, programs can extend the behavior of the other functions.For the protocol to work, user-defined methods on = and < must preserve the following properties:

- Identity:
- If (a = b), then (a = b).
- Transitivity:
- If (a < b) and (b < c), then (a < c).
- If (a = b) and (b = c), then (a = c).
- Trichotomy:
- 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).In the general case, the behavior of comparison operators when applied to instances of

`<complex>`

is implementation defined. This is to allow implementations to support IEEE floating point when comparing NaNs. However, when instances of`<rational>`

and instances of`<float>`

are compared, it is defined that the instance of`<float>`

is first converted to a rational and then an exact comparison is performed.

`~`

[Function]Returns true if its argument is false; otherwise returns false.

**Signature:**-
`~`

Þ*thing**boolean* **Arguments:**-
*thing*An instance of`<object>`

. **Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if
*thing*is false. Returns false if*thing*is true.

`==`

[Function]Compares two objects for identity.

**Signature:**-
*object1*Þ`== object2`

*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if object1 and object2 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.

At an implementation level, this will usually mean that the objects are pointers to the same storage or are the same immediate value. An extension is made for built-in number classes and characters. Because these objects are not mutable (i.e. cannot be changed), two with the same value will always be the same (and will thus be indistinguishable to programs).

`~==`

[Function]Compares two objects for nonidentity.

**Signature:**-
*object1*Þ`~== object2`

*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if object1 and object2 are not identical. It returns false if they are identical.
If both arguments are instances of

`<complex>`

then the result is computed in an implementation-defined way. Otherwise, the result is computed by`~(object1 == object2)`

.

`=`

[Open Generic Function]Compares two objects for equality.

**Signature:**-
*object1*Þ`= object2`

*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if object1 and object2 are equal. Otherwise, it returns false.
Programmers may define methods for = specialized on classes they define. A programmer may be required to provide an = method when defining subclasses of some predefined classes in order to fullfill the protocol of the class, as described below. For objects which do not have a more specific = method, = returns the same as ==.

= is not guaranteed to return. For example, it may not return when called on circular structures or otherwise unbounded structures.

The generic function

`=`

is inert over the domain`(<complex>, <complex>)`

.

`=`

calls `==`

and returns the result returned by `==`

.sequence = list Þ boolean [G.F. Method]

`~=`

[Function]Compares two objects for inequality.

**Signature:**-
*object1*Þ`~= object2`

*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if object1 and object2 are not equal. It returns false if they are equal.
If both arguments are instances of

`<complex>`

then the result is computed in an implementation-defined way. Otherwise, the result is computed by the expression`~(`

.*object1 = object2)*

`<`

[Open Generic Function]Returns true if its first operand is less than its second operand.

**Signature:**-
*object1*Þ`< object2`

*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if
*object1*is less than*object2*.- The generic function
`<`

is inert over the domain`(<complex>, <complex>)`

.

- The generic function

` < `

string2 Þ `=`

on corresponding elements, and stopping when the elements are not `=`

. If one string is a strict prefix of the other, the shorter string is considered the "smaller" one. For variations on string comparison (such as comparisons that ignore case), different comparison operators must be used.

`>`

[Function]Returns true if its first operand is greater than its second operand.

**Signature:**-
*object1*`>`

*object2*Þ*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if
*object1*is greater than*object2*.If both arguments are instances of

`<complex>`

then the result is computed in an implementation-defined way. Otherwise, the result is computed by the expression`(`

.*object2 < object1)*

`<=`

[Function]Returns true if its first operand is less than or equal to its second operand.

**Signature:**-
*object1*`<=`

*object2*Þ*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if
*object1*is less than or equal to*object2*.If both arguments are instances of

`<complex>`

then the result is computed in an implementation-defined way. Otherwise, the result is computed by the expression`~(`

.*object2 < object1)*

`>=`

[Function]Returns true if its first operand is greater than or equal to its second operand.

**Signature:**-
*object1*`>=`

*object2*Þ*boolean* **Arguments:**-
*object1*An instance of`<object>`

.*object2*- An instance of
`<object>`

.

**Values:**-
*boolean*An instance of`<boolean>`

. **Description:**- Returns true if
*object1*is greater than or equal to*object2*.If both arguments are instances of

`<complex>`

then the result is computed in an implementation-defined way. Otherwise, the result is computed by the expression`~(`

.*object1 < object2)*

`min`

[Function]Returns the least of its arguments.

**Signature:**-
`min`

*object1*`#rest`

*objects*Þ*object2* **Arguments:**-
*object1*An instance of`<object>`

.*objects*- Zero or more instances of
`<object>`

.

**Values:**-
*object2*An instance of`<object>`

. **Description:**- Returns the least of its arguments.
`min`

operates by calling`<`

, and therefore is applicable to any objects for which`<`

is defined.

`max`

[Function]Returns the greatest of its arguments.

**Signature:**-
`max`

#rest*object1**objects*Þ*object2* **Arguments:**-
*object1*An instance of`<object>`

.*objects*- Zero or more instances of
`<object>`

.

**Values:**-
*object2*An instance of`<object>`

. **Description:**- Returns the greatest of its arguments.
`max`

operates by calling`<`

, and therefore is applicable to any objects for which`<`

is defined.

Dylan Reference Manual - 17 OCT 1995 [Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker