Function: let-when-compile

let-when-compile is a macro defined in lisp-mode.el.gz.

Signature

(let-when-compile BINDINGS &rest BODY)

Documentation

Like let*, but allow for compile time optimization.

Use BINDINGS as in regular let*, but in BODY each usage should be wrapped in eval-when-compile. This will generate compile-time constants from BINDINGS.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/lisp-mode.el.gz
(defmacro let-when-compile (bindings &rest body)
  "Like `let*', but allow for compile time optimization.
Use BINDINGS as in regular `let*', but in BODY each usage should
be wrapped in `eval-when-compile'.
This will generate compile-time constants from BINDINGS."
  (declare (indent 1) (debug let))
  (letrec ((loop
            (lambda (bindings)
              (if (null bindings)
                  (macroexpand-all (macroexp-progn body)
                                   macroexpand-all-environment)
                (let ((binding (pop bindings)))
                  (cl-progv (list (car binding))
                      (list (eval (nth 1 binding) t))
                    (funcall loop bindings)))))))
    (funcall loop bindings)))