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#66750: Unhelpful text in C-h v for variables with a lambda form as value Date: Sun, 29 Oct 2023 00:14:24 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32621"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66750@debbugs.gnu.org, Andrea Corallo , Stefan Kangas To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 29 05:16:08 2023 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 1qwxDb-0008GR-CK for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Oct 2023 05:16:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwxD8-00062X-Tv; Sun, 29 Oct 2023 00:15:38 -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 1qwxD0-00061v-BP for bug-gnu-emacs@gnu.org; Sun, 29 Oct 2023 00:15:35 -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 1qwxCz-0002D4-Oh for bug-gnu-emacs@gnu.org; Sun, 29 Oct 2023 00:15:30 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qwxDV-0000vN-ON for bug-gnu-emacs@gnu.org; Sun, 29 Oct 2023 00:16: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: Sun, 29 Oct 2023 04:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66750 X-GNU-PR-Package: emacs Original-Received: via spool by 66750-submit@debbugs.gnu.org id=B66750.16985529103483 (code B ref 66750); Sun, 29 Oct 2023 04:16:01 +0000 Original-Received: (at 66750) by debbugs.gnu.org; 29 Oct 2023 04:15:10 +0000 Original-Received: from localhost ([127.0.0.1]:40066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qwxCg-0000u6-8C for submit@debbugs.gnu.org; Sun, 29 Oct 2023 00:15:10 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:49293) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qwxCd-0000tW-6V for 66750@debbugs.gnu.org; Sun, 29 Oct 2023 00:15:08 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 91D05807D1; Sun, 29 Oct 2023 00:14:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1698552867; bh=udTIIXgOBnm5Alne1XADhmkL6dNMucBNfr5Y5aXi3Fc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=iG4b1u/43bHaby1c+VXaTffP6ZYfc4O8+Iz6wUHfEMrtEVdi1k7RAwYNDozzfApX4 ONxzZtlZ7+ILk3ZEvirqLWaNomZjd7I4u1+4byzzlD1dT6cObybPBpMvGUJBnTF11X OiBRljYR9C1YrYuZS+J8uUkbPwdmKGZYGqxkzHU5RrfW98i73xQuT1P83iwkIcAP29 6Aj6h6U73tUqAV6rM5vEHUkJ60bYCvSF1fxOOOYbCNhhg6NXm72IWnoXzOGpgdo5WI lct/jYvrbU7qwGDNECikc1Wz5aPANw172eJfBgIpcfPu+4IIBjNajwDkG4/QsN7Kgp XBxU+6C4ErxRg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5BB0780060; Sun, 29 Oct 2023 00:14:27 -0400 (EDT) Original-Received: from pastel (unknown [45.72.195.71]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 19F751202CB; Sun, 29 Oct 2023 00:14:27 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Sat, 28 Oct 2023 19:59:36 +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:273479 Archived-At: >> > There are lots of detailed changes in eval.c and bytecomp.el (and >> > friends). Also the macro `lambda' in subr.el has been amended to insert >> > the current global defining-symbol if there isn't already a non-nil >> > symbol in that position. >> So the source code can manually provide this extra symbol in `lambda`? >> Where have you found that useful? > The first few functions in debug-early.el and byte-run.el, for a start. > There, there is not yet a defmacro macro. Also in > comp-trampoline-compile, where there doesn't seem to be any other way to > get the name of the primitive into the defining symbol. I think there'll > be quite a few other places, too. Hmm... it seems like keeping the LINE+COL info rather than a surrounding definition would be better in this regard since it wouldn't require any changes at all to the actual lambdas, regardless where they are. >> Hmm... as a user, rather than the enclosing definition I think I'd >> expect to get some kind of source information like FILE+LINE+COL. > Possibly: either is a good deal better than what we have at the moment. The notion of "surrounding definition" is less precise (there can be several lambdas inside a given definition, there can be lambdas outside of any definition, ...). Furthermore, that info is already available to the bytecompiler, so it's actually easier to keep that info. >> Actually, the bytecode functions can already keep the FILE info (in >> the form of the (FILE . OFFSET) cons cell in the docstring slot of the >> bytecode object), we just opt never to expose that FILE info to the user >> (we only use it to fetch the actual docstring). > That's the offset in the .elc file, though, not the source. Yup. [ Tho now that you make me think about it, if we want to be cheap, we could go to that OFFSET position and look around for a `^(defalias` and that might be sufficient to give us "the surrounding definition" in many cases :-) ] >> [ Tho, admittedly, it's also that the byte-compiler only uses such >> (FILE . OFFSET) for named functions, but it wouldn't be hard to change. ] >> As for how/where to store the LINE+COL, I guess (aref form 5) is still >> an option, although, maybe we should store that info alongside the >> docstring, like we already do for the arglist. > Well, the doc string is at (aref form 4). :-) What I meant is that the docstring is in the `.elc` file. So the bytecode object would be literally unchanged, it's just that the bytes found at OFFSET inside FILE would be extended to hold: - the docstring - the human-readable arglist - the LINE+COL info Stefan