From: Andrea Corallo <acorallo@gnu.org>
To: Stefan Monnier via "Emacs development discussions."
<emacs-devel@gnu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Declaring primitive function types
Date: Sun, 03 Mar 2024 03:57:55 -0500 [thread overview]
Message-ID: <yp1plwb1ylo.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <jwvcyscgwm7.fsf-monnier+emacs@gnu.org> (Stefan Monnier via's message of "Sat, 02 Mar 2024 16:45:28 -0500")
Stefan Monnier via "Emacs development discussions."
<emacs-devel@gnu.org> writes:
>> DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0,
>> doc: /* Return t if OBJECT is an array (string or vector). */,
>> (function (t) boolean))
>> (Lisp_Object object)
>> {
>> if (ARRAYP (object))
>> return Qt;
>> return Qnil;
>> }
>
> Everything else being equal (haha!), I'd vote to put the type *before*
> the doc. But I guess you did it this way so we don't have to touch
> the DEFUNs to which we don't add an annotation.
That's correct, I wanted to minimize the diff of the patch.
> I think it looks pretty good.
>
>> I guess another option would have been having the type in the doc
>> argument (as for attributes) and have something like:
>>
>> DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0,
>> doc: /* Return t if OBJECT is an array (string or vector). */
>> type: (function (t) boolean))
>> (Lisp_Object object)
>> {
>> if (ARRAYP (object))
>> return Qt;
>> return Qnil;
>> }
>>
>> This would complexify a little things as we'd need 'make-docfile' to
>> parse it and generate something somewhere that we read afterwards.
>
> I'd much rather not go through `make-docfile`.
>
> You could probably still make it work without `make-docfile`, just by
> tweaking `Fsubr_type` so it skips the "type:" before calling Fread.
>
>> I like the solution of the prototype for its simplicity but maybe people
>> find the last one is more aesthetic?
>
> Not sure about "aesthetic", but the presence of `type:` does make it more
> obvious what this is about. The number of arguments to DEFUN is high
> enough that it's toeing the limits of BoA style.
>
> Another option along those lines would be:
>
> DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0,
> doc: /* Return t if OBJECT is an array (string or vector). */
> ((type (function (t) boolean))))
> (Lisp_Object object)
>
> which could accommodate extensions like
>
> DEFUN (...
> doc: /* ... */
> ((type (function (t) boolean))
> (obsolete "use pcase, of course" "24,1")
> (usage (fn ARGS [DOCSTRING] [INTERACTIVE] BODY...))))
Okay thanks, I'll try to come-up with something that does not add a new
argument to the macro.
Andrea
next prev parent reply other threads:[~2024-03-03 8:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 9:55 Declaring primitive function types Andrea Corallo
2024-03-02 21:45 ` Stefan Monnier via Emacs development discussions.
2024-03-03 8:57 ` Andrea Corallo [this message]
2024-03-03 14:31 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yp1plwb1ylo.fsf@fencepost.gnu.org \
--to=acorallo@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.