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#67455: (Record source position, etc., in doc strings, and use this in *Help* and backtraces.) Date: Sun, 07 Apr 2024 23:16:13 -0400 Message-ID: References: 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="27061"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 67455@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 08 05:17:26 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 1rtfVe-0006je-29 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Apr 2024 05:17:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtfV9-0008C4-TL; Sun, 07 Apr 2024 23:16:55 -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 1rtfV9-0008Bw-5r for bug-gnu-emacs@gnu.org; Sun, 07 Apr 2024 23:16:55 -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 1rtfV8-0005m4-Ti for bug-gnu-emacs@gnu.org; Sun, 07 Apr 2024 23:16:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rtfVF-0005SI-R5 for bug-gnu-emacs@gnu.org; Sun, 07 Apr 2024 23:17: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: Mon, 08 Apr 2024 03:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67455 X-GNU-PR-Package: emacs Original-Received: via spool by 67455-submit@debbugs.gnu.org id=B67455.171254619120852 (code B ref 67455); Mon, 08 Apr 2024 03:17:01 +0000 Original-Received: (at 67455) by debbugs.gnu.org; 8 Apr 2024 03:16:31 +0000 Original-Received: from localhost ([127.0.0.1]:45081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtfUl-0005QF-3j for submit@debbugs.gnu.org; Sun, 07 Apr 2024 23:16:31 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21179) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtfUj-0005Q3-Ml for 67455@debbugs.gnu.org; Sun, 07 Apr 2024 23:16:30 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 66FAB80BC1; Sun, 7 Apr 2024 23:16:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1712546175; bh=n9P42IekFT9nDOQ2MOiwDGjl4XWcWsBcpQCVEDk8kPA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nCVWbyh6YgDBumfexN0UzGCmpeAz6zt2JCGNVH/Jcm2lcHnpdULpyV0mqyNAhFQyZ bE9n/S4JvmNTl51iL5br50FyFnnfPI8cGgUkHrsqd/KvtywtG5M9aV50D2ufbQz33g DnOcOziIa7e4sbJr81lngXeDWF67Vu6H4xPbwOPTdZ7BJtwvinfAM4L0/cSeK5j0Zk YDP5xO+YvfWkWI8wB0sVAexCOFbnrv0mSesfHCdefdQr0mxnzSkU7Hv8PdzZDkrb4X /G+edehZrn+M1kYPouiUu6kUytIMyK2V7WDBF19dEoSZgHicu+BAHpzCRtTrRS9nXR 7rFr7BZHf3BRA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 36314803B1; Sun, 7 Apr 2024 23:16:15 -0400 (EDT) Original-Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 06A05120250; Sun, 7 Apr 2024 23:16:14 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Sun, 7 Apr 2024 10:57:50 +0000") 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:282906 Archived-At: > Pretending the problem doesn't exist won't solve it. In the ;POS... > structures for a lambda, there are two pointers - one to the definition > of the lambda, the other to the point of use. Fancy. Could you give me an example where I see this in play? [ To help me understand also what you mean by "definition of the lambda" and "point of use"? ] I looked around but all I could see where position info like [foo foo.el 41 nil] which point to "the definition" of the function. >> BTW, AFAIK the above is conceptually what the byte-compiler does (except >> it performs a few more transformations between `macroexp--expand-all` >> and `strip-all-symbol-positions`). > It is a bad idea to conflate these two radically different uses of SWPs. In what way are they radically different uses of SWPs? >> Is it the case that `cl-defmethod` generates a function whose source >> position (partly) points to `generic.el:403` if `cl-generic.el` was >> interpreted but not if it compiled? > No, the intention is that the source positions are independent of whether > the code is compiled. Good. So why do the interpreted and compiled cases need to be "radically different uses of SWPs"? >> > (defmacro foo (lambda bar) >> > `(cons ,lambda ,bar)) > >> > expands to > >> > (macro closure (t) (lambda bar) ";POS^^^A^A^A [foo *scratch* 158 nil] >> > " (list 'cons lambda bar)) > >> IIUC your reader will make the `lambda` formal argument into an SWP. >> Where is that SWP stripped? > > In macroexp--expand-all in the "guard arm" near the end. How? `macroexp--expand-all` will not be passed this `lambda` because it's not an *expression*. `eval-buffer` of a buffer containing the above defmacro does: 1 -> (macroexp--expand-all (defalias 'foo (cons 'macro #'{foo} (lambda (# bar) ";POS=01=01 [foo foo.el 41 nil]\n" `(cons ,lambda = ,bar))))) | 2 -> (macroexp--expand-all 'foo) | 2 <- macroexp--expand-all: 'foo | 2 -> (macroexp--expand-all (cons 'macro #'{foo} (lambda (# bar) ";POS=01=01 [foo foo.el 41 nil]\n" `(cons ,lambda ,bar)))) | | 3 -> (macroexp--expand-all 'macro) | | 3 <- macroexp--expand-all: 'macro | | 3 -> (macroexp--expand-all #'{foo} (lambda (# bar)= ";POS=01=01 [foo foo.el 41 nil]\n" `(cons ,lambda ,bar))) | | | 4 -> (macroexp--expand-all ";POS=01=01 [foo foo.el 41 nil]\n") | | | 4 <- macroexp--expand-all: ";POS=01=01 [foo foo.el 41 nil]\n" | | | 4 -> (macroexp--expand-all `(cons ,lambda ,bar)) | | | | 5 -> (macroexp--expand-all 'cons) | | | | 5 <- macroexp--expand-all: 'cons | | | | 5 -> (macroexp--expand-all lambda) | | | | 5 <- macroexp--expand-all: lambda | | | | 5 -> (macroexp--expand-all bar) | | | | 5 <- macroexp--expand-all: bar | | | 4 <- macroexp--expand-all: (list 'cons lambda bar) | | 3 <- macroexp--expand-all: #'{foo} (lambda (# bar)= ";POS=01=01 [foo foo.el 41 nil]\n" (list 'cons lambda bar)) | 2 <- macroexp--expand-all: (cons 'macro #'{foo} (lambda (# bar) ";POS=01=01 [foo foo.el 41 nil]\n" (list 'cons lambda bar))) 1 <- macroexp--expand-all: (defalias 'foo (cons 'macro #'{foo} (lambda (# bar) ";POS=01=01 [foo foo.el 41 nil]\n" (list 'cons lam= bda bar)))) So we see that indeed it returns code where the formal argument `lambda` is (incorrectly) a SYMPOS. Yet somehow the sympos is stripped after macroexpansion somewhere since `(symbol-function 'foo)` shows the resulting function doesn't have any symposes in it. >> > so it is clear this case is getting handled OK. I'm afraid I can't >> > point out the exact place in the code at the moment where this is >> > getting done. >> I think it would be good to know, so as to be able to decide whether >> it'll indeed always work right, or we just got lucky this time. > See above. Yes, please, see above =F0=9F=99=82 >> Could you explain what you think makes it intrinsically complex? > The mass of detail that needs dealing with that Emacs has collected over > the decades. As a counter question, why do you think the exercise ought > to be simple (assuming you do think this)? Because you solved the hard part when you added the symposes for the compil= er. Stefan