From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58563: 29.0.50; Generic functions and advertised-calling-convention Date: Sun, 16 Oct 2022 13:24:30 +0300 Message-ID: <878rlgjcbl.fsf@tcd.ie> Reply-To: "Basil L. Contovounesios" Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37314"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier To: 58563@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 16 12:26:39 2022 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 1ok0qr-0009Vv-MU for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 12:26:37 +0200 Original-Received: from localhost ([::1]:44204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ok0qq-0001bS-4h for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 06:26:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ok0pK-0001al-IM for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 06:25:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44388) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ok0pJ-0005lZ-TM for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 06:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ok0pJ-0004V5-ND; Sun, 16 Oct 2022 06:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Oct 2022 10:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58563 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Stefan Monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.166591588417253 (code B ref -1); Sun, 16 Oct 2022 10:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Oct 2022 10:24:44 +0000 Original-Received: from localhost ([127.0.0.1]:43466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ok0p2-0004UA-7r for submit@debbugs.gnu.org; Sun, 16 Oct 2022 06:24:44 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:33212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ok0oy-0004U1-Fp for submit@debbugs.gnu.org; Sun, 16 Oct 2022 06:24:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ok0oy-0001ZY-16 for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 06:24:40 -0400 Original-Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:43539) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ok0ou-0005fY-Lt for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 06:24:39 -0400 Original-Received: by mail-ej1-x633.google.com with SMTP id d26so19068296eje.10 for ; Sun, 16 Oct 2022 03:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=H/7i41DZVZT5fZ6zLUa8noAppUlVp083Nfr40bX+xws=; b=e5MQb/+MNAgVUoXV4+xIfnLsLCcfC69m81fCjguoBI/G1/XTte1yzvLou+jbbnvR98 1jA/orLN3IjB/2xV3eKt7G2TXIzQmMioo924IsOKs5Fx1f9HBY/viOBVqg8DQf4Qcpc/ 6/xYpmhRS9FaIDdmGxbZHk87TC6qR0ZcGEdtbtdrhlW6oYQWUtsKDwAPeILg4Y2vm9bF cvtnyYBWeJpXcFNhYpfXDErdeyRZGbrLg8eSM8V+gFbJp2dZd6B4gmFPcGjQvy0ErWiz M0gojRMIuV9riC9Lg401y3yu43WgsHDabah3dgJPZL4Sfm2XG3lwXKNzDOMY+dG1zNha 6CNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H/7i41DZVZT5fZ6zLUa8noAppUlVp083Nfr40bX+xws=; b=Rv14IAwPrQP6f6guyHnzujtMUhWj0OpdMu0oBxk2zSuMqYNdhSXlP8+3ZQDfTekwnE smaOUXakRvKVJ7RVA+xQUFcExp4VDeb8ArXDW6L3hutEoUEyRz8Vp6tzUB9az5xyH8pN O4IG1IrEIXwDWRvAk2Brs/kYCy+5NgJ5bAkOR68Ze+Ph5Q4CVVLF6j58uUyXzpblKa3/ W/7glgJhk8WZIwV72pTOOzUukVCxms9stqgScO7tUaQt08AfO930f2fUzQLFGv7PRg1B l+5+gO/rSMopLEe2uBDpq3v5XcXuSHkpixq3H594Mhqgoa2R/19RFVnxYsBhkzPO98Fb XSvw== X-Gm-Message-State: ACrzQf2rh9V/Q+L8UXqbnTwX5tRiRc1M9hG2EaphHRBQwWQq/udPW6kS 2cq1EUhWOHdK6Q6O8ptgH7DelH7RSfsUQg== X-Google-Smtp-Source: AMsMyM73jzN0vh5cfSXgUej8dfC5X7OZrlcSlxEH40KI2/PhLEQMv0bIcLWD3DmOZrPo8grVpdETPw== X-Received: by 2002:a17:906:1350:b0:77f:76a7:a0f with SMTP id x16-20020a170906135000b0077f76a70a0fmr4586511ejb.503.1665915872471; Sun, 16 Oct 2022 03:24:32 -0700 (PDT) Original-Received: from localhost ([2a02:587:321f:7e8a:d9:365a:ced1:b3d1]) by smtp.gmail.com with ESMTPSA id kv2-20020a17090778c200b0077e6be40e4asm4440506ejc.175.2022.10.16.03.24.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 03:24:32 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=contovob@tcd.ie; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:245625 Archived-At: Further to https://bugs.gnu.org/58531#25, generic functions do not currently support advertised-calling-convention very well (or vice versa). For example, starting with: (cl-defgeneric my-foo (x &optional _y) "Frobnicate X." (declare (advertised-calling-convention (x) "29.1")) x) Any code that calls my-foo with two arguments correctly gives rise to a warning during byte-compilation. C-h f also shows the expected arglist, but not for methods: my-foo is a Lisp closure. (my-foo X) Frobnicate X. This is a generic function. Implementations: (my-foo X &optional _Y) Undocumented More importantly, if we now do: (cl-defmethod my-foo ((x symbol) &optional _y) "Frobnicate X the symbol." (declare (advertised-calling-convention (x) "29.1")) x) Then my-foo's symbol-function is overwritten and its entry in advertised-signature-table is no longer found, so byte-compilation no longer warns about incorrect usage, and C-h f regresses to displaying: my-foo is a byte-compiled Lisp function. (my-foo X &optional Y) Frobnicate X. This is a generic function. Implementations: (my-foo (X symbol) &optional _Y) Frobnicate X the symbol. (my-foo X &optional _Y) Undocumented Note that, unlike with cl-defgeneric, the declare form in cl-defmethod does not expand to a call to set-advertised-calling-convention. If set-advertised-calling-convention is called after the cl-defmethod, then the advertised-calling-convention is preserved (or rather reinstated), but only until the next cl-defmethod is defined (which could happen in third-party code). I guess either advertised-signature-table should be extended to allow for the nature of generic functions, or cl-defmethod should be taught to preserve such function properties (or both). I wonder if cl-defgeneric should be the single source of this function property, or whether any cl-defmethod should be able to overload it. Thoughts? Thanks, -- Basil In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2022-10-16 built on tia Repository revision: 07222447b6c9e75b713fe3b3954952fbb0e40c71 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Debian GNU/Linux bookworm/sid