Contents    Page-10    Prev    Next    Page+10    Index   

Simple Partial Evaluator...

      (progn                                ; (fn args)
        (setq args (mapcar #'(lambda (x)
                               (mix x env)) ; mix the args
                           (cdr code)))
        (if (and (every #'constantp args)   ; if all constant args
                 (not (member fn '(print    ; and no
                        prin1 princ error   ; compile-time
                        format))))          ; side-effects
            (kwote (eval (cons fn args)))   ; eval it now
            (if (and (some #'constantp args); if some constant
                     (fndef fn))            ;  & symbolic fn
                (fnmix fn args)             ;  unfold the fn
                (fnopt (cons fn args))))))) ; optimize result

(cons 'bad-code code)) ) ) ))