[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Declaring primitive function types
From: |
Andrea Corallo |
Subject: |
Declaring primitive function types |
Date: |
Fri, 23 Feb 2024 04:55:12 -0500 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Declaring primitive function types,
Andrea Corallo <=