From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: acorallo@gnu.org, basil@contovou.net, 69739@debbugs.gnu.org
Subject: bug#69739: 30.0.50; `type-of` is not precise enough
Date: Mon, 18 Mar 2024 14:56:58 +0200 [thread overview]
Message-ID: <86r0g74s11.fsf@gnu.org> (raw)
In-Reply-To: <jwvv85kcx5k.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Sun, 17 Mar 2024 18:29:10 -0400)
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: basil@contovou.net, acorallo@gnu.org, 69739@debbugs.gnu.org
> Date: Sun, 17 Mar 2024 18:29:10 -0400
>
> > Yes, I think we should document it near type-of, as the explanation
> > when and why to prefer cl-type-of is quite simple and easily
> > understandable.
>
> OK, here's a new (set of) patches (also available in the
> `scratch/object-type` branch). I added the doc as well as a test
> (which pointed to the `subr-primitive-p` problem), and an additional
> hunk which fixes the `subr-primitive-p`.
Thanks, a few nits below.
> +@defun cl-type-of object
> +This function returns a symbol naming @emph{the} type of
> +@var{object}. It usually behaves like @code{type-of}, except
> +that it guarantees to return the most precise type possible, which also
> +implies that the specific type it returns may change depending on the
> +Emacs version. For this reason, as a rule you should never compare its
> +return value against some fixed set of types.
> +
> +@example
> +(object-type 1)
> + @result{} fixnum
> +@group
> +(object-type 'nil)
> + @result{} null
> +(object-type (record 'foo))
> + @result{} foo
"object-type"?
> DEFUN ("type-of", Ftype_of, Stype_of, 1, 1, 0,
> doc: /* Return a symbol representing the type of OBJECT.
> The symbol returned names the object's basic type;
> -for example, (type-of 1) returns `integer'. */)
> +for example, (type-of 1) returns `integer'.
> +Contrary to `cl-type-of' the returned type is not always the most
^^
I think we want a comma there.
> +DEFUN ("cl-type-of", Fcl_type_of, Scl_type_of, 1, 1, 0,
> + doc: /* Return a symbol representing the type of OBJECT.
> +The symbol returned names the most specific possible type of the object.
^^^^^^^^^^^^^^^^^^^
I think "The returned symbol" is better here, as it prevents a
possible confusion (whether "returned" alludes to "symbol" or to
"names").
> +for example, (object-type nil) returns `null'.
^^^^^^^^^^^
"object-type"?
> (defsubst subr-primitive-p (object)
> - "Return t if OBJECT is a built-in primitive function."
> + "Return t if OBJECT is a built-in primitive written in C."
> (declare (side-effect-free error-free))
> (and (subrp object)
> (not (subr-native-elisp-p object))))
>
> +(defsubst primitive-function-p (object)
> + "Return t if OBJECT is a built-in primitive function."
> + (declare (side-effect-free error-free))
> + (and (subrp object)
> + (not (or (subr-native-elisp-p object)
> + (eq (cdr (subr-arity object)) 'unevalled)))))
Should these doc strings mention the special case of special form,
which each one of them treats differently?
next prev parent reply other threads:[~2024-03-18 12:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 23:19 bug#69739: 30.0.50; `type-of` is not precise enough Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-12 13:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-12 14:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-12 16:07 ` Rudolf Schlatte
2024-03-13 22:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-12 13:58 ` Eli Zaretskii
2024-03-12 14:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-12 15:02 ` Eli Zaretskii
2024-03-12 15:39 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-13 11:55 ` Eli Zaretskii
2024-03-14 16:56 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-15 9:42 ` Andrea Corallo
2024-03-15 10:54 ` Andrea Corallo
2024-03-15 9:51 ` Basil L. Contovounesios
2024-03-15 14:09 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-15 15:18 ` Eli Zaretskii
2024-03-17 22:29 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-18 12:56 ` Eli Zaretskii [this message]
2024-03-18 13:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-15 11:50 ` 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=86r0g74s11.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=69739@debbugs.gnu.org \
--cc=acorallo@gnu.org \
--cc=basil@contovou.net \
--cc=monnier@iro.umontreal.ca \
/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).