Next: Operator Reduction, Previous: In-line Coding, Up: Declarations [Contents][Index]
The replace-operator
declaration is provided to inform the
compiler that certain operators may be replaced by other operators
depending on the number of arguments.
For example:
Declaration:
(declare (replace-operator (map (2 map-2) (3 map-3))))
Replacements:
(map f x y z) → (map f x y z) (map f x y) → (map-3 f x y) (map f x) → (map-2 f x) (map f) → (map f) (map) → (map)
Presumably map-2
and map-3
are efficient versions of
map
that are written for exactly two and three arguments
respectively. All the other cases are not expanded but are handled by
the original, general map
procedure, which is less efficient
because it must handle a variable number of arguments.
The syntax of this declaration is
(replace-operator (name (nargs1 value1) (nargs2 value2) …))
where
any
, else
or otherwise
.
'constant
A constant.
variable
A variable.
(primitive primitive-name [arity])
The primitive procedure named primitive-name. The optional element arity, a non-negative integer, specifies the number of arguments that the primitive accepts.
(global var)
A global variable.
The meanings of these fields are:
any
, else
or otherwise
, then the operation is
replaced with a call to the corresponding valueN.
Only one of the nargsN may be of this form.
any
, else
or otherwise
, then the operation is not
replaced.
Next: Operator Reduction, Previous: In-line Coding, Up: Declarations [Contents][Index]