replace-operator declaration is provided to inform the
compiler that certain operators may be replaced by other operators
depending on the number of arguments.
(declare (replace-operator (map (2 map-2) (3 map-3))))
(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)
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) ...))
- name is a symbol.
- nargs1, nargs2 etc. are non-negative integers, or one of the following symbols:
- value1, value2 etc. are simple expressions in one of these forms:
- A constant.
- A variable.
- The primitive procedure named primitive-name. The optional element arity, a non-negative integer, specifies the number of arguments that the primitive accepts.
- A global variable.
The meanings of these fields are:
- name is the name of the operator to be reduced. If is is not shadowed (for example, by a let) then it may be replaced according to the following rules.
- If the operator has nargsN arguments then it is replaced with a call to valueN with the same arguments.
- If the number of arguments is not listed, and one of the nargsN is
otherwise, then the operation is replaced with a call to the corresponding valueN. Only one of the nargsN may be of this form.
- If the number of arguments is not listed and none of the nargsN is
otherwise, then the operation is not replaced.