From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#69739: 30.0.50; `type-of` is not precise enough Date: Mon, 18 Mar 2024 14:56:58 +0200 Message-ID: <86r0g74s11.fsf@gnu.org> References: <86o7bjtuvj.fsf@gnu.org> <86il1rtrvm.fsf@gnu.org> <86a5n2tkga.fsf@gnu.org> <877ci3stzu.fsf@epfl.ch> <86zfuz7cbw.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="757"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acorallo@gnu.org, basil@contovou.net, 69739@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 18 13:57: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 1rmCYk-000AYZ-R0 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Mar 2024 13:57:46 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmCYP-0001DH-Cd; Mon, 18 Mar 2024 08:57:25 -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 1rmCYO-0001D3-B6 for bug-gnu-emacs@gnu.org; Mon, 18 Mar 2024 08:57:24 -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 1rmCYO-0006t0-2V for bug-gnu-emacs@gnu.org; Mon, 18 Mar 2024 08:57:24 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rmCYz-00035X-Ur for bug-gnu-emacs@gnu.org; Mon, 18 Mar 2024 08:58:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Mar 2024 12:58:01 +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.171076667411856 (code B ref 69739); Mon, 18 Mar 2024 12:58:01 +0000 Original-Received: (at 69739) by debbugs.gnu.org; 18 Mar 2024 12:57:54 +0000 Original-Received: from localhost ([127.0.0.1]:51164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rmCYs-00035A-A1 for submit@debbugs.gnu.org; Mon, 18 Mar 2024 08:57:54 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rmCYp-00034w-Bb for 69739@debbugs.gnu.org; Mon, 18 Mar 2024 08:57:52 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmCY5-0006pS-NL; Mon, 18 Mar 2024 08:57:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=4CkAX34Z+GIRATjB4L8tm+L+gzG4D+SbguVCXJYT+UY=; b=JjHDBlLnBrWj EBR2N8hpNqK5EjS+GQ1hxbHj+xkmEbKnfk+EmZxgWhM7198kqp8k4lm8QbImTXy0JBvz0P7La+RWm 2JnvSsSSrnTu54OT4lGQRFYOkYcIM4YAF7DEuhWSgyJZpYvkE6GkLVOQn09fRbuuykiLDv5HHbHp3 8CNnuiA2yJbY2b37b2+kYtO2TDXYKBoFWwtPFmMIq4BO768UK/O+CXisSNJP1j5v0PHQHVNXayeeq UyQD5+GHZKZmGOSxdirLONEGxY3pisLsN9lUg1pCetHQV6A1vNyqgNQR9xBin9/EzSQ+3I9Wg+X9K g7LK6Re356iLHtVs1LiIAg==; In-Reply-To: (message from Stefan Monnier on Sun, 17 Mar 2024 18:29:10 -0400) 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:281800 Archived-At: > From: Stefan Monnier > 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?