From unknown Sat Aug 16 20:56:03 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23486 <23486@debbugs.gnu.org> To: bug#23486 <23486@debbugs.gnu.org> Subject: Status: 25.0.93; Modules: features missing from make_function Reply-To: bug#23486 <23486@debbugs.gnu.org> Date: Sun, 17 Aug 2025 03:56:03 +0000 retitle 23486 25.0.93; Modules: features missing from make_function reassign 23486 emacs submitter 23486 Philipp Stephani
>
> To solve (1)=E2=80=93(3), I'd propose replacing the "arity&qu= ot; arguments with a
> true arglist specification.=C2=A0 This could either be at the C level,= e.g.
>
>=C2=A0 =C2=A0 =C2=A0ptrdiff_t num_mandatory_args, char** mandatory_arg_= names,
>=C2=A0 =C2=A0 =C2=A0ptrdiff_t num_optional_args, char** optional_arg_na= mes,
>=C2=A0 =C2=A0 =C2=A0char* rest_arg_name
>
> or by requiring to pass a Lisp argument list.
>
> To solve (4) I'd propose to pass another value for the interactive= form,
> probably as emacs_value* (to support non-interactive functions).
>
> As an alternative, if people feel this would require too many
> parameters, I'd propose reverting the change that adds the documen= tation
> string.=C2=A0 A docstring without arglist is not very useful.=C2=A0 We= could also
> remove the arity parameters and have the C function check the arity
> itself.
I think adding "(fn ARG1 ARG2...)" to the docstring would solve (= 1)-(3).
What's lacking is a way to add this automagically like DEFUN does.=C2= =A0 And
getting the parameters in C variables like DEFUN would also be nice.
Philipp Stephani <p.stephani2@gmail.c= om> writes:
>
>>=C2=A0 I think adding "(fn ARG1 ARG2...)" to the docstrin= g would solve (1)-(3).
>
> That doesn't work, because Emacs ignores this syntax when the
> arguments are provided explicitly, and since a module function is just=
> a (lambda (&rest args) ...) under the hood, the arglist is always = just
> (&rest args).
I don't know what you mean here.
=C2=A0 =C2=A0 (defun foo (&rest args)
=C2=A0 =C2=A0 =C2=A0 "Do foo.
=C2=A0 =C2=A0 \(fn ARG1 ARG2)")
<f1> f foo RET gives
=C2=A0 =C2=A0 foo is a Lisp function.
=C2=A0 =C2=A0 (foo ARG1 ARG2)
=C2=A0 =C2=A0 Do foo.
Philipp Stephani <p.stephani2@gmail.com> writes:
> As an alternative, if people feel this would require too many
> parameters, I'd propose reverting the change that adds the documen= tation
> string.=C2=A0 A docstring without arglist is not very useful.=C2=A0 We= could also
> remove the arity parameters and have the C function check the arity
> itself.
Looking at this a bit closer, I do think this adds too many parameters,
and in particular, requiring to pass in names for positional parameters
just makes no sense.=C2=A0 The names are never used (except for displaying<= br> documentation).
But removing the docstring is not great.=C2=A0 IMO, the right solution here=
is to use a subr-like object instead of a lambda, as suggested in a
FIXME in emacs-module.c:
=C2=A0 /* FIXME: Use a bytecompiled object, or even better a subr.=C2=A0 */=
Then the arity could be checked with `subr-arity' or similar.This is now done (commit 31fded0370c3aa6d2c4370c= ae21cdb7475873483). This fixes (1) through (3). (4) through (6) are still o= pen. That's probably OK if the limitations are documented; modules can = always do the equivalent of (eval '(defun ...)) to get complete support= .=C2=A0