3.2 Making declarations
type-reduce
declaration specifies that within the scope of the declaration all objects that belong to a specified supertype can be treated as belonging to a specified subtype. For example, a program can declare that all numbers should be treated as fixnum integers. Atype-reduce
declaration might be simpler to use than adding manytype
declarations to your code. Thetype-reduce
declaration has the following form:
(declare (type-reduce type1 type2))The arguments type1 and type2 must be type specifiers; the type type2 must be a subtype of type1.
For example, if you have an application that uses only fixnum arithmetic, the following proclamation would allow the Compiler to compile all arithmetic operators as fixnum operators without requiring any additional declarations:
(proclaim '(type-reduce number fixnum))If you have an application that uses both fixnum and nonfixnum arithmetic but uses only fixnum integer values, you could use the following declaration:
(declare (type-reduce integer fixnum))See Section 3.3 on page 49 for more information about using
type-reduce
declarations to restrict arithmetic operators.
Generated with Harlequin WebMaker