Function: byte-compile--reify-function

byte-compile--reify-function is a byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-compile--reify-function FUN)

Documentation

Return an expression which will evaluate to a function value FUN.

FUN should be an interpreted closure.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile--reify-function (fun)
  "Return an expression which will evaluate to a function value FUN.
FUN should be an interpreted closure."
  (let* ((args (aref fun 0))
         (body (aref fun 1))
         (env (aref fun 2))
         (docstring (function-documentation fun))
         (iform (interactive-form fun))
         (preamble `(,@(if docstring (list docstring))
                     ,@(if iform (list iform))))
         (renv ()))
    ;; Turn the function's closed vars (if any) into local let bindings.
    (dolist (binding env)
      (cond
       ((consp binding)
        (push `(,(car binding) ',(cdr binding)) renv))
       ((eq binding t))
       (t (push `(defvar ,binding) body))))
    (if (null renv)
        `(lambda ,args ,@preamble ,@body)
      `(let ,renv (lambda ,args ,@preamble ,@body)))))