Function: byte-compile-let
byte-compile-let is a byte-compiled function defined in
bytecomp.el.gz.
Signature
(byte-compile-let FORM)
Documentation
Generate code for the let or let* form FORM.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile-let (form)
"Generate code for the `let' or `let*' form FORM."
(let ((clauses (cadr form))
(init-lexenv nil)
(is-let (eq (car form) 'let)))
(when is-let
;; First compute the binding values in the old scope.
(dolist (var clauses)
(push (byte-compile-push-binding-init var) init-lexenv)))
;; New scope.
(let ((byte-compile-bound-variables byte-compile-bound-variables)
(byte-compile--lexical-environment
byte-compile--lexical-environment))
;; Bind the variables.
;; For `let', do it in reverse order, because it makes no
;; semantic difference, but it is a lot more efficient since the
;; values are now in reverse order on the stack.
(dolist (var (if is-let (reverse clauses) clauses))
(unless is-let
(push (byte-compile-push-binding-init var) init-lexenv))
(let ((var (if (consp var) (car var) var)))
(if (byte-compile-bind var init-lexenv)
(pop init-lexenv))))
;; Emit the body.
(let ((init-stack-depth byte-compile-depth))
(byte-compile-body-do-effect (cdr (cdr form)))
;; Unbind both lexical and dynamic variables.
(cl-assert (or (eq byte-compile-depth init-stack-depth)
(eq byte-compile-depth (1+ init-stack-depth))))
(byte-compile-unbind clauses init-lexenv
(> byte-compile-depth init-stack-depth))))))