[Next] [Previous] [Up] [Top] [Contents] [Index]

5 Types and Classes

Limited Types

Limited types are subtypes of classes constrained by additional criteria. Limited types are created with the generic gunction limited. limited(<integer> ,min: 0 max: 255) and limited(<array>, of: <single-float>) are examples of limited types which are useful both for error checking and for optimization of compiled code.

Limited types are not classes.

Limited Type Constructor

Limited types are created with the generic function limited. The first argument to limited is a class. Depending on the class, additional keyword arguments are allowed to specify the constraints of the limited type.

Not all classes support limited; the methods for limited are documented individually on page 249.

Limited Integer Types

Limited integer types are subtypes of <integer> containing integers which fall within a specifed range. The range is specified by min: and max: keyword arguments to limited.

For example:

// accepts integers between -1000 and 1000 inclusive.
define method f (x :: limited(<integer>, min: -1000,
max: 1000))
...
end method f;

//accepts all strictly positive integers.
define method f (x :: limited(<integer>, min: 1))
...
end method f;

Limited Integer Type Protocol

If w, x, y, and z are integers, the following equivalences hold:

Limited Collection Types

Limited collection types are subtypes of <collection> (and of subclasses of <collection>) which may be constrained to be a specified size and to contain elements of a specified type.

A complete description of limited collection types is given in "Limited Collection Types" on page 124 in Chapter 8, "Collections."


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

Generated with Harlequin WebMaker