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: Sat, 28 Oct 2023 15:13:16 -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="20618"; 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 Sat Oct 28 21:13:55 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 1qwokt-0005CK-H6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Oct 2023 21:13:55 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwokc-00009w-Dq; Sat, 28 Oct 2023 15:13: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 1qwokU-00009P-J4 for bug-gnu-emacs@gnu.org; Sat, 28 Oct 2023 15:13:31 -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 1qwokU-0007CO-Aa for bug-gnu-emacs@gnu.org; Sat, 28 Oct 2023 15:13:30 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qwokz-0006Wp-Vv for bug-gnu-emacs@gnu.org; Sat, 28 Oct 2023 15:14:02 -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, 28 Oct 2023 19:14: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.169852044025079 (code B ref 66750); Sat, 28 Oct 2023 19:14:01 +0000 Original-Received: (at 66750) by debbugs.gnu.org; 28 Oct 2023 19:14:00 +0000 Original-Received: from localhost ([127.0.0.1]:39576 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qwokx-0006WR-RY for submit@debbugs.gnu.org; Sat, 28 Oct 2023 15:14:00 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:56468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qwoku-0006WD-ML for 66750@debbugs.gnu.org; Sat, 28 Oct 2023 15:13:58 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D39F280283; Sat, 28 Oct 2023 15:13:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1698520397; bh=2mK4vcDN6CjNngTPb0Hk/Y6t94nZ/mdRUvvglKIF2G4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=aMbOydptnmBhcSyM7b/bCrkiEKZsyZlBM9sItFb1rH7vTP409HE49wkUpBTPhCaMU 9MthaGJ9OVmRZKeKfhMVzsJhqzmU5MDyzHiLyHygCq6l0+BZ1wKyareUGxcPdeXbyI atu4NKvSFGfg1hPOzEPRmFY/7sQCwcTv8nx+vQx7YBovlJpWJRZIodbSE2SF6Aq7OP Ry8OMnnmNq+9/ff4Y/ndN051ohQEQV36JzUALZWzpocpxeVKJRKJ9pb1GuJMG9m7TE LxKjddRO5s0YSUnH55io4deONo3VsU6oXOrjVrgylrjKzBg3h1h6Gy+pn54j126BQc 8fTK7uaknc/gA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BB98B807D7; Sat, 28 Oct 2023 15:13:17 -0400 (EDT) Original-Received: from pastel (unknown [45.72.195.71]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8C9ED120352; Sat, 28 Oct 2023 15:13:17 -0400 (EDT) In-Reply-To: (Alan Mackenzie's message of "Sat, 28 Oct 2023 18:17:04 +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:273466 Archived-At: >> I like the idea of keeping better track of the origin of lambda >> expressions (tho, admittedly, the same problem occurs with other kinds >> of data: I have several times been faced with a keymap or a char-table, >> wondering where the heel it came from). > Maybe something similar might be possible for those type of objects. [ Hmm... food for thought... ] >> I took a look at > >> git log -p main..origin/feature/named-lambdas > >> but that's 127kB, so ... could [you] briefly describe the overall design >> (IOW, how it's seen by ELisp programmers, byte-compiler hackers, and >> ELisp users)? > > Certainly. Each lambda expression has (usually) a defun within which it > is defined. Sometimes it's in a defvar, or defcustom. That > @dfn{defining symbol} is recorded in the lambda form in one of three > ways: > (i) For a cons form, it's (cadr form), a new field inserted between the > symbol `lambda' and the argument list. > (ii) For a byte-compiled form, it's (aref form 5), this new field going > after the doc string and before any interactive form in the compiled > form. These two change the visible representation of functions, so I wouldn't be surprised if they break some odd hack out there. For (i), do we actually care enough to keep that info (IME the functions are usually compiled, and if they're not the code itself usually makes it fairly easy to find the code's origin)? For (ii), why did you choose slot 5, thus moving the interactive-form slot? > 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? >> Also, what other approaches have you considered/tried and what were the >> problems you've encountered, if any? > feature/named-lambdas was originally intended for use in backtraces. > For the current bug, I've considered individually replacing each lambda > with a named defun, so that C-h v will show that name rather than an 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. If we give up on keeping that extra info in interpreted functions, the FILE+LINE+COL information is readily available to the byte-compiler, thanks to that famous Alan guy. 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). [ 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. The way we do it for the arglist is hideous and a pain in the rear (I blame the maintainers who accepted my patch back then), so it would be an opportunity to "do it right" this time. Stefan