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#56596: 29.0.50; void-variable cl--nm Date: Sat, 16 Jul 2022 19:19:41 -0400 Message-ID: References: <8735f18mxg.fsf@pollock-nageoire.net> <87cze5s44q.fsf@gnus.org> <87bktp6ifn.fsf@pollock-nageoire.net> Reply-To: Stefan Monnier 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="34171"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 56596@debbugs.gnu.org, Lars Ingebrigtsen To: "Pierre L. Nageoire" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 17 01:20:16 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 1oCr55-0008fw-7i for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Jul 2022 01:20:15 +0200 Original-Received: from localhost ([::1]:53542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oCr53-0000Cl-SV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Jul 2022 19:20:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oCr4s-0000C1-EP for bug-gnu-emacs@gnu.org; Sat, 16 Jul 2022 19:20:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oCr4s-00084W-5Z for bug-gnu-emacs@gnu.org; Sat, 16 Jul 2022 19:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oCr4r-00024o-QE for bug-gnu-emacs@gnu.org; Sat, 16 Jul 2022 19:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Jul 2022 23:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56596 X-GNU-PR-Package: emacs Original-Received: via spool by 56596-submit@debbugs.gnu.org id=B56596.16580135947963 (code B ref 56596); Sat, 16 Jul 2022 23:20:01 +0000 Original-Received: (at 56596) by debbugs.gnu.org; 16 Jul 2022 23:19:54 +0000 Original-Received: from localhost ([127.0.0.1]:46318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oCr4k-00024L-3g for submit@debbugs.gnu.org; Sat, 16 Jul 2022 19:19:54 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:56233) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oCr4g-000247-CO for 56596@debbugs.gnu.org; Sat, 16 Jul 2022 19:19:52 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 485498067B; Sat, 16 Jul 2022 19:19:44 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id F2727805B2; Sat, 16 Jul 2022 19:19:42 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1658013582; bh=bM7+E+SUBzfLrHOkVfuVXdIZQA22Bt5YWIOYEoDNFa4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NqS7JuWUAbTCFx2eIzZ+sSstBZgCqWJVPUmsNKim0GTIojvg+ZAZBZXf2hDCswuSv ugEutw8VvBF2pH0L3oAUXKB3sGAItD7cllwozFd8f9rW8eJwPNEe925dAznEwG/H9z RFL6fPKFLgvVRKC6MJouHqbtYJj/SNPziVf3BbCFU2tG2M5NpNpWb0IHtFQDWLLdWc akU6C9aze9cepq7JvpJieEPcNxgYsgb+YIFZZ3j1xAGLa4y9vxQMcA3sCtnBRFd2GN wtRwVMBSsqTtxwZtLzkRvg1sP6CpUupShlU6S+3HxAt1oe57kXJMqW2fbdRRmajHsn X9HQKbxMCMQOQ== Original-Received: from alfajor (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C03E61201B4; Sat, 16 Jul 2022 19:19:42 -0400 (EDT) In-Reply-To: <87bktp6ifn.fsf@pollock-nageoire.net> (Pierre L. Nageoire's message of "Sat, 16 Jul 2022 20:06:36 +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" Xref: news.gmane.io gmane.emacs.bugs:237216 Archived-At: >> I can reproduce this -- but only when using dynamic binding. When using >> lexical binding, things work fine. Indeed, `cl-defmethod` (and `cl-defgeneric`) aren't guaranteed to work in dynbind code. They often do, admittedly. >> I've added Stefan to the CCs; perhaps he has some comments. > > I suspect that cl-generic implementation has recently changed and that > it should not be used nowadays exactly like it has been. Any small > explanations from Stefan would be greatly appreciated ! The "next method" is not known when we compile `cl-defmethod` but it is known when we build the "effective method", which is expected to be done much less often than actual calls to that method. The old code for `cl-defmethod` turned (cl-defmethod I ((d raw-daughter)) (format "the daughter of %s" (cl-call-next-method))) into something like (cl-..register (raw-daughter) (lambda (cnm d) (format "the daughter of %s" (apply cnm)))) forcing the caller to build a `cnm` closure which captures the args list containing the value of the `d` argument. Also it made it difficult to implement `next-method-p` since that requires digging into this `cnm` closure to see if it's one of those that would signal no-next-method. The new code instead is a bit like: (cl-..register (raw-daughter) (lambda (nm) (lambda (&rest args) (let ((cnm (lambda (&rest cnmargs) (apply nm (or cnmargs args))))) (destructive-bind (d) args (format "the daughter of %s" (apply cnm))))))) This basically moves some of the code from the caller to here, which doesn't seem to buy us very much but: - it makes it much easier to implement `next-method-p` because now we have access to the actual "next method", rather than to a closure that combines the next methods with the saved arg list, so it's much easier to tell if the next method is the one that signals no-next-method. - we occasionally get to skip building the `cnm` closure because we can use =CE=BB-lifting instead (basically the byte-compiler gets to see both parts of the code together and can thus change it: with this new code we could actually improve the code generated by the byte-compiler even further). Problem is that the new code relies on the use of currying (see how `nm` and `args` are now passed in a curried fashion), which is only possible with lexical scoping. Stefan