mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-04-25 10:50:30 -07:00
si_process_lambda_list: process all variables in an uniform manner
The comment mentioned that aux variables (the sixth value) are returned the same way as requireds, optionals and keywords however factually that was not the case - the number of variables was not the first element of the list. This commit updates the function and all its callers.
This commit is contained in:
parent
b62cf6b7ed
commit
8ba1bb888a
5 changed files with 18 additions and 17 deletions
|
|
@ -2885,16 +2885,15 @@ si_process_lambda(cl_object lambda)
|
|||
* VALUES(5) = allow-other-keys ; flag &allow-other-keys
|
||||
* VALUES(6) = (N aux1 init1 ... ) ; auxiliary variables
|
||||
*
|
||||
* 1°) The prefix "N" is an integer value denoting the number of
|
||||
* variables which are declared within this section of the lambda
|
||||
* list.
|
||||
* 1) The prefix "N" is an integer value denoting the number of variables
|
||||
* which are declared within this section of the lambda list.
|
||||
*
|
||||
* 2°) The INIT* arguments are lisp forms which are evaluated when
|
||||
* no value is provided.
|
||||
* 2) The INIT* arguments are lisp forms which are evaluated when no value is
|
||||
* provided.
|
||||
*
|
||||
* 3°) The FLAG* arguments is the name of a variable which holds a
|
||||
* boolean value in case an optional or keyword argument was
|
||||
* provided. If it is NIL, no such variable exists.
|
||||
* 3) The FLAG* arguments is the name of a variable which holds a boolean
|
||||
* value in case an optional or keyword argument was provided. If it is NIL,
|
||||
* no such variable exists.
|
||||
*/
|
||||
|
||||
cl_object
|
||||
|
|
@ -3088,15 +3087,16 @@ si_process_lambda_list(cl_object org_lambda_list, cl_object context)
|
|||
|
||||
OUTPUT:
|
||||
if ((nreq+nopt+(!Null(rest))+nkey) >= ECL_CALL_ARGUMENTS_LIMIT)
|
||||
FEprogram_error("LAMBDA: Argument list is too long, ~S.", 1,
|
||||
org_lambda_list);
|
||||
@(return CONS(ecl_make_fixnum(nreq), lists[0])
|
||||
FEprogram_error("LAMBDA: Argument list is too long, ~S.", 1, org_lambda_list);
|
||||
|
||||
@(return
|
||||
CONS(ecl_make_fixnum(nreq), lists[0])
|
||||
CONS(ecl_make_fixnum(nopt), lists[1])
|
||||
rest
|
||||
key_flag
|
||||
CONS(ecl_make_fixnum(nkey), lists[2])
|
||||
allow_other_keys
|
||||
lists[3]);
|
||||
CONS(ecl_make_fixnum(naux), lists[3]))
|
||||
|
||||
ILLEGAL_LAMBDA:
|
||||
FEprogram_error("LAMBDA: Illegal lambda list ~S.", 1, org_lambda_list);
|
||||
|
|
@ -3195,7 +3195,7 @@ ecl_make_lambda(cl_env_ptr env, cl_object name, cl_object lambda) {
|
|||
}
|
||||
ECL_RPLACD(aux, names);
|
||||
}
|
||||
|
||||
auxs = ECL_CONS_CDR(auxs);
|
||||
while (!Null(auxs)) { /* Local bindings */
|
||||
cl_object var = pop(&auxs);
|
||||
cl_object value = pop(&auxs);
|
||||
|
|
|
|||
|
|
@ -353,8 +353,9 @@
|
|||
(when (and key-flag (not allow-other-keys))
|
||||
(push `(si::check-keyword ,rest ',all-keys) extra-stmts))
|
||||
;; 7. construct body
|
||||
(pop aux-vars)
|
||||
(loop while aux-vars
|
||||
do (push (list (pop aux-vars) (pop aux-vars)) let-vars))
|
||||
do (push (list (pop aux-vars) (pop aux-vars)) let-vars))
|
||||
(values (nreverse (delete-if-not #'first let-vars))
|
||||
`(,@(and apply-var `((declare (ignorable ,apply-var))))
|
||||
,@(multiple-value-bind (decl body)
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@
|
|||
(extract-lambda-type-checks function-name requireds optionals
|
||||
keywords ts other-decls)
|
||||
(let* ((declarations other-decls)
|
||||
(let-vars (loop for spec on (nconc new-auxs aux-vars)
|
||||
(let-vars (loop for spec on (nconc new-auxs (rest aux-vars))
|
||||
by #'cddr
|
||||
for name = (first spec)
|
||||
for init = (second spec)
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ keyword argument, the compiler-macro declines to provide an expansion.
|
|||
parse-forms-pass2))
|
||||
;; 5. &aux vars: these are simply set to their initforms after
|
||||
;; parsing of keywords has finished
|
||||
(loop for a on auxs by #'cddr
|
||||
(loop for a on (rest auxs) by #'cddr
|
||||
do (push (first a) bindings-for-body)
|
||||
(push `(setf ,(first a) ,(second a)) aux-setf-forms))
|
||||
;; 6. Finally, we are ready to create the compiler-macro definition
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
(dm-v v `(if (eq ,temp 'missing-keyword) ,init ,temp))
|
||||
(when sv (dm-v sv `(not (eq ,temp 'missing-keyword))))
|
||||
(push k all-keywords)))
|
||||
(do ((l auxs (cddr l))) ((endp l))
|
||||
(do ((l (rest auxs) (cddr l))) ((endp l))
|
||||
(let* ((v (first l))
|
||||
(init (second l)))
|
||||
(dm-v v init)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue