From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Pierre L. Nageoire" Newsgroups: gmane.emacs.bugs Subject: bug#56596: 29.0.50; void-variable cl--nm Date: Mon, 18 Jul 2022 05:36:11 +0200 Message-ID: <871quj6qj8.fsf@pollock-nageoire.net> References: <8735f18mxg.fsf@pollock-nageoire.net> <87cze5s44q.fsf@gnus.org> <87bktp6ifn.fsf@pollock-nageoire.net> 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="27947"; 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: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 18 05:35:13 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 1oDHXN-000727-4e for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Jul 2022 05:35:13 +0200 Original-Received: from localhost ([::1]:51680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDHXL-0003SG-N9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Jul 2022 23:35:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDHXD-0003Qr-1I for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2022 23:35:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDHXC-00089v-LJ for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2022 23:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oDHXC-0004HG-Eo for bug-gnu-emacs@gnu.org; Sun, 17 Jul 2022 23:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Pierre L. Nageoire" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Jul 2022 03:35:02 +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.165811527216399 (code B ref 56596); Mon, 18 Jul 2022 03:35:02 +0000 Original-Received: (at 56596) by debbugs.gnu.org; 18 Jul 2022 03:34:32 +0000 Original-Received: from localhost ([127.0.0.1]:48935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDHWi-0004GR-8C for submit@debbugs.gnu.org; Sun, 17 Jul 2022 23:34:32 -0400 Original-Received: from smtp03.smtpout.orange.fr ([80.12.242.125]:52895 helo=smtp.smtpout.orange.fr) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDHWe-0004GE-2P for 56596@debbugs.gnu.org; Sun, 17 Jul 2022 23:34:30 -0400 Original-Received: from aboulafia ([2.14.36.239]) by smtp.orange.fr with ESMTP id DHWXozBNudt6qDHWYoK193; Mon, 18 Jul 2022 05:34:26 +0200 X-ME-Helo: aboulafia X-ME-Date: Mon, 18 Jul 2022 05:34:26 +0200 X-ME-IP: 2.14.36.239 In-Reply-To: (Stefan Monnier's message of "Sat, 16 Jul 2022 19:19:41 -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" Xref: news.gmane.io gmane.emacs.bugs:237318 Archived-At: Hi Stefan, Thanks for these detailed explanations; I think I will be able to modify my codes to make them work with this new cl-generic implementation. Best regards=20 Stefan Monnier writes: >>> 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