Next Previous Up Top Contents Index

5 Integers

5.3 The Generic-Arithmetic library

The Generic-Arithmetic library exports the functions described in this section from an exported module called generic-arithmetic.

The Generic-Arithmetic library provides a fully extensible version of all arithmetic operations. If an application only uses Generic-Arithmetic, these versions of the operators reduce themselves to be equivalent to those in the Dylan library. But when you use additional implementation libraries, the arithmetic operators are extended.

The Big-Integers library is one such implementation library. It provides a 64-bit implementation of <integer>.

The standard integer implementation in the Dylan library is actually part of the following class hierarchy:

<abstract-integer>
  <integer>
  <big-integer>
    <double-integer>

(The classes <big-integer> and <double-integer> are implementation classes. You do not need to use them.)

The modules in the Generic-Arithmetic library export <abstract-integer> with the name <integer>. They also export a full set of arithmetic operators that use instances of <abstract-integer> rather than instances of <integer> (in the Dylan library naming scheme). However, those operators just fall back to the Dylan library operators until you include an implementation library, such as Big-Integers, in your application.

When you use the Big-Integers library, the arithmetic operators exported by Generic-Arithmetic are enhanced to extend their results to 64-bit integers. If a result is small enough to fit in a Dylan library <integer>, it will be fitted into one.

Note that the Generic-Arithmetic library uses the same naming conventions for arithmetic operators as used by the Dylan library. This means that some renaming is required in modules that require access to both the basic Dylan interfaces and the interfaces supplied by the Generic-Arithmetic library. As described earlier, the notation interface#module is used to denote different interfaces of the same name, where interface is the name of the interface, and module is the name of the module it is exported from.

See "Using special arithmetic features" on page 142 for an example of how to use an implementation library with Generic-Arithmetic.

5.3.1 - Ranges
5.3.2 - Classes
5.3.3 - Specific constructors
5.3.4 - Arithmetic operations
5.3.5 - Iteration constructs
5.3.6 - Exported modules from the Generic-Arithmetic library

Common Dylan and Functional Extensions - 31 Mar 00

Next Previous Up Top Contents Index