/* Eval a sub-expression of the current expression (i.e. in the same
lexical scope). */
-Lisp_Object
-eval_sub (Lisp_Object form)
+static Lisp_Object
+eval_sub_1 (Lisp_Object form)
{
Lisp_Object fun, val, original_fun, original_args;
Lisp_Object funcar;
return val;
}
+
+Lisp_Object
+eval_sub (Lisp_Object form)
+{
+ return scm_c_value_ref (eval_sub_1 (form), 0);
+}
+\f
+static Lisp_Object
+values_to_list (Lisp_Object values)
+{
+ Lisp_Object list = Qnil;
+ for (int i = scm_c_nvalues (values) - 1; i >= 0; i--)
+ list = Fcons (scm_c_value_ref (values, i), list);
+ return list;
+}
+
+DEFUN ("multiple-value-call", Fmultiple_value_call, Smultiple_value_call,
+ 2, UNEVALLED, 0,
+ doc: /* Call with multiple values.
+usage: (multiple-value-call FUNCTION-FORM FORM) */)
+ (Lisp_Object args)
+{
+ Lisp_Object function_form = eval_sub (XCAR (args));
+ Lisp_Object values = Qnil;
+ while (CONSP (args = XCDR (args)))
+ values = nconc2 (Fnreverse (values_to_list (eval_sub_1 (XCAR (args)))),
+ values);
+ return apply1 (function_form, Fnreverse (values));
+}
+
+DEFUN ("values", Fvalues, Svalues, 0, MANY, 0,
+ doc: /* Return multiple values. */)
+ (ptrdiff_t nargs, Lisp_Object *args)
+{
+ return scm_c_values (args, nargs);
+}
\f
DEFUN ("apply", Fapply, Sapply, 1, MANY, 0,
doc: /* Call FUNCTION with our remaining args, using our last arg as list of args.
return Qnil;
}
-DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
+DEFUN ("funcall", Ffuncall1, Sfuncall, 1, MANY, 0,
doc: /* Call first argument as a function, passing remaining arguments to it.
Return the value that function returns.
Thus, (funcall 'cons 'x 'y) returns (x . y).
scm_dynwind_end ();
return val;
}
+
+Lisp_Object
+Ffuncall (ptrdiff_t nargs, Lisp_Object *args)
+{
+ return scm_c_value_ref (Ffuncall1 (nargs, args), 0);
+}
\f
static Lisp_Object
apply_lambda (Lisp_Object fun, Lisp_Object args)