From: Andrea Corallo <acorallo@gnu.org>
To: emacs-devel@gnu.org
Subject: Declaring primitive function types
Date: Fri, 23 Feb 2024 04:55:12 -0500 [thread overview]
Message-ID: <yp1msrr8pz3.fsf@fencepost.gnu.org> (raw)
Hi all,
yesterday night I toyed with some code (scratch/func-type-decls) to move
out the type declaration of primitive functions from
'comp-known-type-specifiers' and move them to where actually functions
are defined.
In order to do that I added an optional argument to the DEFUN macro.
So to get practical 'arrayp' definition goes from:
DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0,
doc: /* Return t if OBJECT is an array (string or vector). */)
(Lisp_Object object)
{
if (ARRAYP (object))
return Qt;
return Qnil;
}
to:
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;
}
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 like the solution of the prototype for its simplicity but maybe people
find the last one is more aesthetic? Also I've the impression that
'make-docfile' was used so far only for problems that were not solvable
with just the DEFUN expansion.
Opinions?
Thanks!
Andrea
PS for lisp functions I'm about to open another thread as I think will
be more efficient to be discuss the two separately
next reply other threads:[~2024-02-23 9:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 9:55 Andrea Corallo [this message]
2024-03-02 21:45 ` Declaring primitive function types Stefan Monnier via Emacs development discussions.
2024-03-03 8:57 ` Andrea Corallo
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=yp1msrr8pz3.fsf@fencepost.gnu.org \
--to=acorallo@gnu.org \
--cc=emacs-devel@gnu.org \
/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.