emacs-devel
[Top][All Lists]
Advanced

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

Re: Inferred function types in the *Help* buffer


From: Andrea Corallo
Subject: Re: Inferred function types in the *Help* buffer
Date: Thu, 01 Jun 2023 15:13:38 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Mattias Engdegård <mattias.engdegard@gmail.com> writes:

> 1 juni 2023 kl. 17.10 skrev Andrea Corallo <acorallo@gnu.org>:
>
>> It's just a very concise and effective way to express the input/output
>> value/types of the function.  I, for one, find it very useful.
>
> If we want to be as nice as possible to the user then perhaps we should 
> massage the output a bit.
> For instance, the `function` part is useless, and using the names of the 
> arguments would be very helpful.
>
> In other words, instead of describing `make-string` as
>
>  (function (integer fixnum &optional t) string)
>
> we could say something like
>
>  LENGTH:integer INIT:fixnum MULTIBYTE -> string
>
> (Not sure how practical it is, I'm just making this up.)

I see your point, I'm not sure how practical this is tho.  'function' is
there to say that the type specifier in object is describing a function.

This is important because a function is just a special kind of object,
and for instance we might have a function returning a function, this way
we can express it with something like:

(function () (function () t))

Another advantage of this notation is that being it borrowed by CL is
already well formalized [1] and deployed.

My opinion is that we might want to extend this in order to be able to
express properties of the functions we want (ex the ones we now have in
byte-opt.el).

> How concise are inferred types, for that matter? I can imagine them becoming 
> pretty voluminous.

They are quite concise, due to the dynamic nature of Lisp the native
compiler can't predict in many cases the return type accurately if at
all.  As mentioned in my emacs -Q ~22% of the loaded functions gets a
non t return type, indeed we might improve in the future.

> By the way, `expt` should have the return type `number`, not `float`. This is 
> just something I noticed in passing; I haven't done any systematic review.

Thanks, the fix is now in the patch.

Best Regards

  Andrea

[1] <http://www.lispworks.com/documentation/lw70/CLHS/Body/04_bc.htm>



reply via email to

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