- case AO_LISP_FUNC_LEXPR:
- case AO_LISP_FUNC_NLAMBDA:
- case AO_LISP_FUNC_MACRO:
- DBGI("bind "); DBG_POLY(args->car); DBG(" = "); DBG_POLY(cons->cdr); DBG("\n");
- next_frame->vals[0].atom = args->car;
- next_frame->vals[0].val = cons->cdr;
- break;
+ if (varargs) {
+ DBGI("bind "); DBG_POLY(varargs); DBG(" = "); DBG_POLY(ao_lisp_cons_poly(vals)); DBG("\n");
+ /*
+ * Bind the rest of the arguments to the final parameter
+ */
+ ao_lisp_frame_bind(next_frame, f, varargs, ao_lisp_cons_poly(vals));
+ } else {
+ /*
+ * Mark the cons cells from the actuals as freed for immediate re-use, unless
+ * the actuals point into the source function (nlambdas and macros), or if the
+ * stack containing them was copied as a part of a continuation
+ */
+ if (lambda->args == AO_LISP_FUNC_LAMBDA && !ao_lisp_stack_marked(ao_lisp_stack)) {
+ ao_lisp_stack->values = AO_LISP_NIL;
+ ao_lisp_cons_free(cons);
+ }