Generating Extension

A generating extension of a program P is a program that generates specializations of P for different values of its static input.

For example, the following is a generating extension of the power program:


(defun f-gen (n) (list 'defun 'h '(x) (g n)))

(defun g (n)
  (if (= n 0)
      1
      (if (= n 1)
          'x
          (if (evenp n)
              (list 'square (g (/ n 2)))
              (list '* 'x (g (- n 1)))))))


> (f-gen 3)
(DEFUN H (X) (* X (SQUARE X)))

> (f-gen 5)
(DEFUN H (X) (* X (SQUARE (SQUARE X))))

Contents    Page-10    Prev    Next    Page+10    Index