From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69739: 30.0.50; `type-of` is not precise enough Date: Tue, 12 Mar 2024 11:39:56 -0400 Message-ID: References: <86o7bjtuvj.fsf@gnu.org> <86il1rtrvm.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23954"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69739@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 12 16:40:48 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rk4FD-000615-TS for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Mar 2024 16:40:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4F2-00077q-Ea; Tue, 12 Mar 2024 11:40:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk4Eu-000745-Ra for bug-gnu-emacs@gnu.org; Tue, 12 Mar 2024 11:40:30 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk4Eu-00026s-0p for bug-gnu-emacs@gnu.org; Tue, 12 Mar 2024 11:40:28 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rk4FS-00075R-7B for bug-gnu-emacs@gnu.org; Tue, 12 Mar 2024 11:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Mar 2024 15:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69739 X-GNU-PR-Package: emacs Original-Received: via spool by 69739-submit@debbugs.gnu.org id=B69739.171025804427210 (code B ref 69739); Tue, 12 Mar 2024 15:41:02 +0000 Original-Received: (at 69739) by debbugs.gnu.org; 12 Mar 2024 15:40:44 +0000 Original-Received: from localhost ([127.0.0.1]:43425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rk4FA-00074n-0X for submit@debbugs.gnu.org; Tue, 12 Mar 2024 11:40:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:42106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rk4F5-00074X-Ou for 69739@debbugs.gnu.org; Tue, 12 Mar 2024 11:40:42 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 154F844083E; Tue, 12 Mar 2024 11:39:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1710257997; bh=1X3J4bvAFstE32nsfoBAh1qrl/RJ8ocW75MchSqKLE0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Ir4pwr6SkIj2m5VpSRBZSCxjy678iHQsrc4BguzNfO30avl/bjdtNGc2wvhpyhbmn IdVKitXwq5UV4oICOoc3ZAEts39G3jcr9Vf6iy9niuiV6rd5J+kHVOdgJ+bo9kpAWD uoY6q6z1SDSqSoHgM3/Aj3rX/cchTePZVnWM3rkGiJelNmylpvyYeFq31/TC/BS2ln QaUVSuLVQxGTe/6wbP5E04q1DZ5NQ0HTDRbfstuZLg+8XVVFF3CXARxCpITZmfBi3K xuuofXB7A2RaEoSKwO9hrdXw/pHEOkr8zwpwL2HIi4wziLdwfdolhui2diyMJJ1nNM KEeHbYcnxlJTg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B333D440782; Tue, 12 Mar 2024 11:39:57 -0400 (EDT) Original-Received: from pastel (69-165-147-56.dsl.teksavvy.com [69.165.147.56]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9298D120675; Tue, 12 Mar 2024 11:39:57 -0400 (EDT) In-Reply-To: <86il1rtrvm.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 12 Mar 2024 17:02:53 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281527 Archived-At: >> >> 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