emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Declaring Lisp function types


From: Andrea Corallo
Subject: Re: Declaring Lisp function types
Date: Sat, 24 Feb 2024 04:21:10 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Adam Porter <adam@alphapapa.net> writes:

> Hi Andrea,
>
>> Finally on top of 'scratch/func-type-decls' (where I there was already a
>> similar work for primitives) I pushed some commits that allows for the
>> following style:
>> (defun sum (a b)
>>   (declare (function (integer integer) integer))
>>   (+ a b))
>> I moved all function declaration out of 'comp-known-type-specifiers'
>> and
>> everything looks functional now.
>> Before writing a ton of changelogs I thought was good to get some
>> feedback anyway. WDYT?
>
> That looks nice to me.  My only suggestion would be to change the
> symbol `function` to `type`, i.e.
>
>   (defun sum (a b)
>     (declare (type (integer integer) integer))
>     (+ a b))
>
> Because it would be more concise and descriptive.

Hi Adam,

I understand your point, probably I had to explain this better in my
original mail.

Fact is, we already use the form (function (ATYPES) RTYPE) as type
specifier for functions.  So (ftype (function (ATYPES) RTYPE)) would be
the most correct form semantically, where `ftype` (or `type` or really
what we prefer) would be the declaration which takes the type specifier
as argument.

Having (declare (function (integer integer) integer)) implies that the
type specifier is a valid declaration as well, or IOW that declare
understands as well type specifiers as a declaration, which I believe is
fine.

I personally find `function` more clear than `type`, but more
importantly I think just having `type` instead of `function` would be
harder to justify from a semantic POV.

Thanks!

  Andrea



reply via email to

[Prev in Thread] Current Thread [Next in Thread]