Function: cl--loop-let
cl--loop-let is a byte-compiled function defined in cl-macs.el.gz.
Signature
(cl--loop-let SPECS BODY PAR)
Documentation
Build an expression equivalent to (let SPECS BODY).
SPECS can include bindings using cl-loops destructuring (not to be
confused with the patterns of cl-destructuring-bind).
If PAR is nil, do the bindings step by step, like let*.
If BODY is setq, then use SPECS for assignments rather than for bindings.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
(defun cl--loop-let (specs body par) ; modifies cl--loop-bindings
"Build an expression equivalent to (let SPECS BODY).
SPECS can include bindings using `cl-loop's destructuring (not to be
confused with the patterns of `cl-destructuring-bind').
If PAR is nil, do the bindings step by step, like `let*'.
If BODY is `setq', then use SPECS for assignments rather than for bindings."
(let ((temps nil) (new nil))
(when par
(let ((p specs))
(while (and p (or (symbolp (car-safe (car p))) (null (cadar p))))
(setq p (cdr p)))
(when p
(setq par nil)
(dolist (spec specs)
(or (macroexp-const-p (cadr spec))
(let ((temp (make-symbol "--cl-var--")))
(push (list temp (cadr spec)) temps)
(setcar (cdr spec) temp)))))))
(while specs
(let* ((binding (pop specs))
(spec (car-safe binding)))
(if (and (consp binding) (or (consp spec) (cl--unused-var-p spec)))
(let* ((nspecs nil)
(expr (car (cdr-safe binding)))
(temp (last spec 0)))
(if (and (cl--unused-var-p temp) (null expr))
nil ;; Don't bother declaring/setting `temp' since it won't
;; be used when `expr' is nil, anyway.
(when (or (null temp)
(and (eq body 'setq) (cl--unused-var-p temp)))
;; Prefer a fresh uninterned symbol over "_to", to avoid
;; warnings that we set an unused variable.
(setq temp (make-symbol "--cl-var--"))
;; Make sure this temp variable is locally declared.
(when (eq body 'setq)
(push (list (list temp)) cl--loop-bindings)))
(push (list temp expr) new))
(while (consp spec)
(push (list (pop spec)
(and expr (list (if spec 'pop 'car) temp)))
nspecs))
(setq specs (nconc (nreverse nspecs) specs)))
(push binding new))))
(if (eq body 'setq)
(let ((set (cons (if par 'cl-psetq 'setq)
(apply #'nconc (nreverse new)))))
(if temps `(let* ,(nreverse temps) ,set) set))
`(,(if par 'let 'let*)
,(nconc (nreverse temps) (nreverse new)) ,@body))))