From: Philipp Stephani <p.stephani2@gmail.com>
To: npostavs@users.sourceforge.net
Cc: 23486@debbugs.gnu.org
Subject: bug#23486: 25.0.93; Modules: features missing from make_function
Date: Sun, 26 Mar 2017 20:02:08 +0000 [thread overview]
Message-ID: <CAArVCkQBmtpRfp7RfY-rXPUqjMfwhXL2GeYHeJyps9Oyeb51fA@mail.gmail.com> (raw)
In-Reply-To: <87inu21o35.fsf@users.sourceforge.net>
[-- Attachment #1: Type: text/plain, Size: 2979 bytes --]
<npostavs@users.sourceforge.net> schrieb am So., 11. Sep. 2016 um 16:56 Uhr:
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > emacs_env::make_function lacks the following features supported by
> > `defun':
> >
> > 1. Functions with both optional and rest arguments.
> > 2. Specification of parameter names.
> > 3. Integration with `help-function-arglist'.
> > 4. Specification of interactive forms.
> > 5. Specification of declare forms.
> > 6. Docstrings containing null or non-Unicode characters.
> >
> > (6) is probably rather unimportant. (5) is probably not implementable
> > (would require wrapping `defun', not `lambda'). (1)–(4) are more severe
> > and quite limit the usefulness of make_function right now; for a
> > truly generic `defun'-like construct one currently has to eval a `defun'
> > form wrapping another function.
>
> Shouldn't modules be providing a DEFUN-like construct instead? That is,
> I thought the idea of modules was to enable writing primitive
> subroutines.
>
I don't know what the idea of modules originally was. However, defun and
DEFUN are composite operations: They create a function object (lambda) and
provide an alias for it. Therefore they can't replace the more primitive
operations. The current module interface design chooses to provide the
primitive operation to make a function object and have the caller call
defalias. That's a reasonable choice.
>
> >
> > To solve (1)–(3), I'd propose replacing the "arity" arguments with a
> > true arglist specification. This could either be at the C level, e.g.
> >
> > ptrdiff_t num_mandatory_args, char** mandatory_arg_names,
> > ptrdiff_t num_optional_args, char** optional_arg_names,
> > char* 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 documentation
> > string. A docstring without arglist is not very useful. 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).
>
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).
> What's lacking is a way to add this automagically like DEFUN does. And
> getting the parameters in C variables like DEFUN would also be nice.
>
Maybe, but not for the module interface. The module interface explicitly
only provides basic primitives, without macro magic or high-level
functions. High-level functionality built on top of the primitives is out
of scope.
[-- Attachment #2: Type: text/html, Size: 4701 bytes --]
next prev parent reply other threads:[~2017-03-26 20:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-09 16:37 bug#23486: 25.0.93; Modules: features missing from make_function Philipp Stephani
2016-09-11 14:13 ` Philipp Stephani
2016-09-11 14:57 ` npostavs
2017-03-26 20:02 ` Philipp Stephani [this message]
2017-03-26 20:22 ` npostavs
2017-03-26 20:40 ` Philipp Stephani
2017-03-27 3:57 ` npostavs
2017-07-04 18:20 ` Philipp Stephani
2017-07-05 3:40 ` npostavs
2020-09-05 13:59 ` Lars Ingebrigtsen
2020-09-13 9:44 ` Philipp Stephani
2020-09-13 13:20 ` Lars Ingebrigtsen
2020-09-13 18:50 ` Philipp Stephani
2020-12-07 16:42 ` Lars Ingebrigtsen
2020-12-12 14:31 ` Philipp Stephani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAArVCkQBmtpRfp7RfY-rXPUqjMfwhXL2GeYHeJyps9Oyeb51fA@mail.gmail.com \
--to=p.stephani2@gmail.com \
--cc=23486@debbugs.gnu.org \
--cc=npostavs@users.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).