Next: , Previous: , Up: Declarations   [Contents][Index]

4.2.3 Operator Replacement

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:


(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)

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.

declaration: replace-operator name …

The syntax of this declaration is

    (nargs1 value1)
    (nargs2 value2)


The meanings of these fields are:

Next: , Previous: , Up: Declarations   [Contents][Index]