From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it Date: Sun, 03 Mar 2024 13:05:27 -0500 Message-ID: References: <170801660982.26727.13226947668211497607@vcs2.savannah.gnu.org> <20240215170330.82819C0F009@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21233"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 03 19:06:19 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rgqE6-0005Ic-W4 for ged-emacs-devel@m.gmane-mx.org; Sun, 03 Mar 2024 19:06:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgqDM-0006z0-5C; Sun, 03 Mar 2024 13:05:32 -0500 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 1rgqDI-0006yW-EM for emacs-devel@gnu.org; Sun, 03 Mar 2024 13:05:28 -0500 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 1rgqDI-0001YA-5f; Sun, 03 Mar 2024 13:05:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=AxfOGfMm1FZsEPdzJKjYuOAxL9hsxyWXpD1maymnSY0=; b=eoAPLaAdOfmMU8bFT2Vz HqQHPm18ZwuYA0t9yaQA8ZW19pIB5kJSF11kAYswcf5zn5ufuBqJP2i7Lu3cg4H5FCtID5RgmwWC5 JO9IU8PTX0/kH4/BKqDBWeGg9G5r68s0e9Nbm5Jnk+0n2P9hubTvG7dBQy0OqPyvu6u6XB/yuRXB0 vliBi4Yu2lfl7qlQRhY92K6NEe54pdBGiWQA2AJInh7sIBVTRC0ZE12HbA/sa+NBPMZQsJjZD113l st/0ogjgee22UK7piIZoenFCntXzOLyayOGbbnUm1Ezr9NMNBX9waROd2qKtT7itI1ZifeQtX5+UY 0n7nTa+KNtwcQA==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rgqDH-0000RB-JZ; Sun, 03 Mar 2024 13:05:27 -0500 In-Reply-To: (Stefan Monnier's message of "Sun, 03 Mar 2024 12:31:22 -0500") X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:316764 Archived-At: Stefan Monnier writes: >> Looks to me better now, this is the content on my Emacs after having >> pushed 8d11b7e4275, please have a look: > > looks OK, thanks (modulo structure/class because I don't know what these = mean). Cool, I'll comeback on the structure/class subject. >> Also is not clear to me if 'cl--typeof-types' should include all types >> or only leaf ones. > > The intention was to include only leaf types, i.e. the types that > `type-of` can return, since the main purpose was to find the (ordered) > list of parents in: > > (cl-generic-define-generalizer cl--generic-typeof-generalizer > ;; FIXME: We could also change `type-of' to return `null' for nil. > 10 (lambda (name &rest _) `(if ,name (type-of ,name) 'null)) > (lambda (tag &rest _) > (and (symbolp tag) (assq tag cl--typeof-types)))) > >> The original was inconsistent on this, > > Maybe that was an oversight. > Do you remember which inconsistency you had noticed in this respect? I remember (symbol-with-pos symbol atom) (symbol atom), there might have been others. >> this version evidently includes all types but should be easy to >> generate only based on the leaf ones if necessary. > > Having extra types doesn't bring any benefit that I can see but is > fairly harmless (it may just slow down ever so slightly a few method > dispatches, when we have a miss in the method cache). Mmmmh, I tried: =3D=3D=3D=3D=3D=3D=3D --- a/lisp/emacs-lisp/cl-preloaded.el +++ b/lisp/emacs-lisp/cl-preloaded.el @@ -117,8 +117,12 @@ cl--supertypes-for-typeof-types (cl--supertypes-for-typeof-types-rec type) (merge-ordered-lists cl--supertypes-lanes-res))) +(defun cl--type-leaf-p (type) + (null (assq type cl--type-hierarchy))) + (maphash (lambda (type _) - (push (cl--supertypes-for-typeof-types type) cl--typeof-types)) + (when (cl--type-leaf-p type) + (push (cl--supertypes-for-typeof-types type) cl--typeof-types= ))) cl--direct-supertypes-of-type) (defconst cl--all-builtin-types =3D=3D=3D=3D=3D=3D This generates as 'cl--typeof-types': ((subr-primitive subr function atom) (subr-native-elisp subr function atom) (module-function function atom) (byte-code-function compiled-function function atom) (cons list sequence) (null list sequence boolean symbol atom) (string array sequence atom) (char-table array sequence atom) (bool-vector array sequence atom) (vector array sequence atom) (keyword symbol-with-pos symbol atom) (fixnum integer number number-or-marker integer-or-marker atom) (bignum integer number number-or-marker integer-or-marker atom) (marker number-or-marker integer-or-marker atom) (float number number-or-marker atom) (obarray atom) (overlay atom) (window-configuration atom) (process atom) (window atom) (buffer atom) (frame atom) (hash-table atom) (terminal atom) (thread atom) (mutex atom) (condvar atom) (font-spec atom) (font-entity atom) (font-object atom) (user-ptr atom) (tree-sitter-parser atom) (tree-sitter-node atom) (tree-sitter-compiled-query atom) (structure atom) (class atom)) Which looks okay to me at a first glance, but make check explodes =F0=9F=A4= =B7... I might be doing something wrong. Andrea