unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 69739@debbugs.gnu.org
Subject: bug#69739: 30.0.50; `type-of` is not precise enough
Date: Tue, 12 Mar 2024 11:39:56 -0400	[thread overview]
Message-ID: <jwvbk7jpjze.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86il1rtrvm.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 12 Mar 2024 17:02:53 +0200")

>> >> Still, any change as suggested here would be an incompatible change, so
>> >> there's risk it'll break some code out there (`type-of` is not used very
>> >> often, but it *is* used).  Another option is to introduce a new function
>> >> which does the same as `type-of` but with changes like the ones above.
>> >> (we could even decide to give it a `cl-generic-` prefix to discourage
>> >> its use elsewhere so we can be more free to change its return value in
>> >> the future).
>> > I'd prefer a non-breaking change, if possible and reasonable.
>> 
>> Suggestion for a good name for that new function?
>
> cl-generic-type-of is one.
>
>> Should it make `type-of` obsolete?
>
> I don't have an opinion on this.  Depends on how much type-of is used,
> I guess.  Maybe we should wait for the next major release and decide
> whether to deprecate then?

In my review of uses of `type-of`, I found:

- The most common seemed to be when generating error messages like
  (error "Arg should be an int rather than a %s" (type-of arg))
- The next most common was misuses like (eq (type-of FOO) 'BAR)
  which should be using `BAR-p` instead (or `cl-typep`).
- The next most common was when `type-of` is applied to a struct
  (i.e. it returns the same as (aref FOO 0)).  Since this was new
  functionality in Emacs-26, I'm surprised at how widespread it is.
- There were a few that are combined with case/pcase and would probably
  be better served by `cl-typecase`.

I think that marking it obsolete wouldn't be an option if the new
function is named something like `cl-generic-type-of`: it would have to
be a more "neutral" name.

The reason why I'd like to make it obsolete (if it can't be changed) is
to try and avoid having two slightly-different functions where most
users don't actually care about the difference.


        Stefan






  reply	other threads:[~2024-03-12 15:39 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 [this message]
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
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=jwvbk7jpjze.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=69739@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --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).