unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Corallo <acorallo@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 73626@debbugs.gnu.org
Subject: bug#73626: 30.0.91; Type specifiers of functions
Date: Wed, 23 Oct 2024 18:29:06 -0400	[thread overview]
Message-ID: <yp1ttd2sbbh.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <86msjkxdf5.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 04 Oct 2024 15:25:50 +0300")

Hi Eli,

sorry for being late on this.

Eli Zaretskii <eliz@gnu.org> writes:

> To reproduce:
>
>   emacs -Q
>   C-h f sort-lines RET
>
> (That particular function is just an example, basically, any function
> should do.)
>
> Observe in the *Help* buffer:
>
>   sort-lines is an autoloaded interactive byte-code-function in
>   ‘sort.el’.
>
>   (sort-lines REVERSE BEG END)
>
> If sort.el was native-compiled, you will see this instead:
>
>   sort-lines is an autoloaded interactive native-comp-function in
>   ‘sort.el’.
>
>   (sort-lines REVERSE BEG END)
>
> So far so good, but in a long-running Emacs session I see this:
>
>   sort-lines is an autoloaded interactive native-comp-function in
>   ‘sort.el’.
>
>   (sort-lines REVERSE BEG END)
>
>   Inferred type: (function (t t t) t)  <<<<<<<<<<<<<<<<<<<<<<
>
> and sometimes this:
>
>   bobp is a primitive-function in ‘src/editfns.c’.
>
>   (bobp)
>
>   Declared type: (function nil boolean)  <<<<<<<<<<<<<<<<<<<<<
>
> These Declared/Inferred type thingies are not documented anywhere,
> AFAICT.  If one looks really hard, one can find in "Declare Form" the
> description of "(ftype TYPE &optional FUNCTION)", but still nothing
> about declared/inferred.  I see in help-fns.el:help-fns--signature
> that we call comp-function-type-spec to get this information, and the
> doc string of comp-function-type-spec says:
>
>   Return the type specifier of FUNCTION.
>
> But there are no matches for "type specifier" anywhere in the ELisp
> manual, and comp-function-type-spec itself is not documented there.
>
> Even after looking and finding all those pieces of the puzzle, the
> overall picture is not clear.  The following is missing, and should be
> documented in the ELisp manual:
>
>  . what is the importance of inferred vs declared type

The user get to know that the function type was computed by the compiler
or manually declared by the user.

>  . how to read the type specifiers,

The format is the same described for type declarations ((elisp)Top >
Functions > Declare Form).

I agree we should probably better document this somewhere else, probably
in Lisp Data Types?

> and in particular what do those "t" members mean,

t is a type documented (elisp)Top > Lisp Data Types > Type Hierarchy

> and more generally, which forms can appear in the
>    car of the cons cell returned by comp-function-type-spec

Hope I answered before.

>  . why "C-h f" shows this information only for some functions and not
>    for others, and what is the significance of that

C-h f does not show the inferred type if the functions has still to be
native compiled and loaded, the reason is simply that is the native
compiler computing the type.

> Bottom line: we decided that this information is important enough to
> show it in the *Help* buffer, so we should explain its arcane parts to
> make them useful.

Agree. Is '(elisp)Top > Lisp Data Types' a reasonable place for that?
Otherwise where should we do it?

Thanks

  Andrea





  parent reply	other threads:[~2024-10-23 22:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 12:25 bug#73626: 30.0.91; Type specifiers of functions Eli Zaretskii
2024-10-19  7:01 ` Eli Zaretskii
2024-10-23 22:29 ` Andrea Corallo [this message]
2024-10-24 15:47   ` Eli Zaretskii
2024-10-25  9:35     ` Andrea Corallo
2024-10-25 10:19       ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yp1ttd2sbbh.fsf@fencepost.gnu.org \
    --to=acorallo@gnu.org \
    --cc=73626@debbugs.gnu.org \
    --cc=eliz@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).