Skip to content
Snippets Groups Projects
Commit a532b41a authored by Philipp Marek's avatar Philipp Marek
Browse files

Rename WHEN-LET* argument, to avoid possible INITIAL-FORM vs. FORMS confusion.

parent 106bb10c
No related branches found
No related tags found
No related merge requests found
...@@ -57,8 +57,8 @@ implicit PROGN." ...@@ -57,8 +57,8 @@ implicit PROGN."
(when (and ,@variables) (when (and ,@variables)
,@forms)))) ,@forms))))
(defmacro when-let* (bindings &body forms) (defmacro when-let* (bindings &body body)
"Creates new variable bindings, and conditionally executes FORMS. "Creates new variable bindings, and conditionally executes BODY.
BINDINGS must be either single binding of the form: BINDINGS must be either single binding of the form:
...@@ -76,18 +76,18 @@ corresponding value. INITIAL-FORM expressions can refer to variables ...@@ -76,18 +76,18 @@ corresponding value. INITIAL-FORM expressions can refer to variables
previously bound by the WHEN-LET*. previously bound by the WHEN-LET*.
Execution of WHEN-LET* stops immediately if any INITIAL-FORM evaluates to NIL. Execution of WHEN-LET* stops immediately if any INITIAL-FORM evaluates to NIL.
If all INITIAL-FORMs evaluate to true, then FORMS are executed as an implicit If all INITIAL-FORMs evaluate to true, then BODY is executed as an implicit
PROGN." PROGN."
(let ((binding-list (if (and (consp bindings) (symbolp (car bindings))) (let ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
(list bindings) (list bindings)
bindings))) bindings)))
(labels ((bind (bindings forms) (labels ((bind (bindings body)
(if bindings (if bindings
`((let (,(car bindings)) `((let (,(car bindings))
(when ,(caar bindings) (when ,(caar bindings)
,@(bind (cdr bindings) forms)))) ,@(bind (cdr bindings) body))))
forms))) body)))
`(let (,(car binding-list)) `(let (,(car binding-list))
(when ,(caar binding-list) (when ,(caar binding-list)
,@(bind (cdr binding-list) forms)))))) ,@(bind (cdr binding-list) body))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment