Subject: bug#40968: 28.0.50; (apply nil)

From: Pip Cet <[email-masked]>
Date: Wed, 6 May 2020 07:26:36 +0000

On Wed, May 6, 2020 at 1:51 AM Stefan Kangas <[email-masked]> wrote:
> Pip Cet <[email-masked]> writes:
> > I'm very confused by the behavior of `apply' when given only a single
> > argument: when it's a nonempty list, the argument gets spread out and
> > passed to Ffuncall (I guess this might be useful sometimes). When it's
> > nil, Ffuncall gets called with nargs == 0 and Emacs crashes, at least
> > sometimes.
> >
> > Should we fix the special case or raise apply's minimum argument count to 2?
>
> I'm personally not a big fan of raising the minimum argument count,
> thereby changing the function signature and making it harder to
> understand.

Thanks. I disagree that it would be harder to understand, though: "the
first argument is a function to call, the last argument is a list of
arguments" is easy to understand when there are >= 2 arguments, but
for a single argument they're in contradiction, aren't they? Indeed,
I'd read Fapply's current docstring:

Call FUNCTION with our remaining args, using our last arg as list of args.

as implying that (apply FUNCTION) is equivalent to (funcall FUNCTION)

> We should just fix the bug, IMHO.

I don't think we can "just" fix the bug. We need to fix Fapply, change
the byte compiler to accept single-argument apply, reformulate the
docstring to describe this case, and probably fix the Lisp manual as
well. I don't think all that is worth it, to be honest, to save
someone the trouble of having to write (apply (car LIST) (cdr LIST))
rather than (apply LIST) (if that is, indeed, what they meant).