What is the argument count limit to a function call?
I think that max-specpdl-size
is related to answer:
This variable defines the limit on the total number of local variable bindings and ‘unwind-protect’ cleanups that are allowed before Emacs signals an error
but I don't think that defun
makes local binding using let
.
I try (macroexpand-all '(defun my (x) (+ x 1))) C-u C-x e
and get:
(defalias (quote my) (function (lambda (x) (+ x 1))))
So I check eval.c
for evaluator code:
apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count) {
EMACS_INT numargs;
register Lisp_Object *arg_vector;
numargs = XFASTINT (Flength (args));
SAFE_ALLOCA_LISP (arg_vector, numargs);
...
which leads to SAFE_ALLOCA_LISP
:
#define SAFE_ALLOCA_LISP(buf, nelt) \
do { \
if ((nelt) <= lisp_word_count (sa_avail)) \
(buf) = AVAIL_ALLOCA ((nelt) * word_size); \
else if ((nelt) <= min (PTRDIFF_MAX, SIZE_MAX) / word_size) \
{ \
Lisp_Object arg_; \
(buf) = xmalloc ((nelt) * word_size); \
arg_ = make_save_memory (buf, nelt); \
sa_must_free = true; \
record_unwind_protect (free_save_value, arg_); \
} \
else \
memory_full (SIZE_MAX); \
} while (false)
That piece is hard for me to understand… Rest of the code doesn't seem to expose any restriction but I am unsure…
Compare with Common Lisp constants: LAMBDA-PARAMETERS-LIMIT and CALL-ARGUMENTS-LIMIT.