From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#66750: Unhelpful text in C-h v for variables with a lambda form as value Date: Wed, 1 Nov 2023 20:30:26 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16424"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66750@debbugs.gnu.org, Andrea Corallo , Stefan Kangas , acm@muc.de To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 01 21:31:49 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 1qyHsS-00049S-UH for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Nov 2023 21:31:49 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyHs9-0000ZY-Pq; Wed, 01 Nov 2023 16:31:29 -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 1qyHs8-0000ZF-2u for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 16:31:28 -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 1qyHs7-0006zW-RM for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 16:31:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qyHsg-0004C4-AR for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 16:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Nov 2023 20:32:02 +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.169887067716030 (code B ref 66750); Wed, 01 Nov 2023 20:32:02 +0000 Original-Received: (at 66750) by debbugs.gnu.org; 1 Nov 2023 20:31:17 +0000 Original-Received: from localhost ([127.0.0.1]:52676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyHrw-0004AT-FL for submit@debbugs.gnu.org; Wed, 01 Nov 2023 16:31:17 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:63266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyHrr-00049g-Cu for 66750@debbugs.gnu.org; Wed, 01 Nov 2023 16:31:14 -0400 Original-Received: (qmail 74429 invoked by uid 3782); 1 Nov 2023 21:30:30 +0100 Original-Received: from acm.muc.de (p4fe15848.dip0.t-ipconnect.de [79.225.88.72]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 01 Nov 2023 21:30:29 +0100 Original-Received: (qmail 1447 invoked by uid 1000); 1 Nov 2023 20:30:26 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de 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:273622 Archived-At: Hello, Stefan. On Wed, Nov 01, 2023 at 14:11:33 -0400, Stefan Monnier wrote: > >> Bootstrap problems are rare, and difficult to predict, so we fix them in > >> a reactive way. Debugging a bootstrap is generally more difficult. > > I'm fully aware of this, having spent a significant part of the last few > > years doing just that. I aim to make it easier, as I have already done > > to a certain degree. > Exactly. That makes you put much more emphasis on this aspect than it > generally deserves. *Very* few Emacs users ever do that. That's just your view. You're wrong, here. I've put little emphasis on bootstrap problems. That they are handled is a side effect of handling everything. > > That doesn't seem relevant to bootstrapping bugs. Using gdb on part of > > the bootstrap is quite difficult. > GDB is my "go to" tool when I have an error during bootstrap and I find > it fairly easy to use. OK, I found it very difficult to get a working command line for this. Maybe if you do it often enough it becomes second nature. > >> We shouldn't design the featureset for the corner case of when the > >> bootstrap fails, because it is a very small fraction of the use-cases, > >> that 99.99% of Emacs users never face. > > We should design the feature set to handle _ALL_ cases, including that > > of bootstrapping. That's why I wrote debug-early.el, for example; it's > > proved its worth, certainly for me personally. > Note that `early-debug.el` doesn't handle "_ALL_" cases: it's only used > for those cases where the normal debugger can't be used. That's twisted reasoning. early-debug.el will handle anything that gets thrown at it. > Before catering to the same use-cases as early-debug, we should cater to > the use cases of the average user/developer who's never getting close to > the bootstrap. I disagree. I don't understand why you want to split off (some of) "the use cases of the average user" and only handle those cases. My intention is to handle _ALL_ cases, and you find this objectionable for some reason. > >> Fist, I did not make a claim to the contrary, so the burden of proof is > >> not on me. This said, I believe there is ample evidence out there, > >> because all the programming tools I've ever used try first and foremost > >> to let you jump to the corresponding source code. The source code is > >> what programmers are familiar with, so being able to jump from the > >> backtrace to the corresponding source code is generally the best known > >> way to help the user find the pertinent info. > > Even better is if the relevant information is present on the screen or > > in the backtrace without having to jump to the source code. > How are you going to fix the problem without going to the source code? You're being contrary again. My intention is that the problem should be better understood before going to the source code - in fact better to understand which source code is relevant. > > This is the point of the defining symbol. The "jumping" is only > > straightforward from a running Emacs session. From a batch mode > > backtrace (e.g. from bootstrapping or ERT), it is much > > more cumbersome. > If your batch session's output is piped to an auto-reverted file in > compilation-mode (mine usually is, FWIW), it's small matter of making > sure the format is recognized. In other words, assume the user is advanced enough to go through all these motions, just to be able to work the way you do. I suspect most users will not be doing this. I certainly don't (at least, not yet). > Still, I refuse to change the syntax of `lambda` just to make it > slightly easier to debug the odd bootstrap problem. For crying out loud, I've explained to you often enough, the syntax of lambda is _NOT_, I repeat _NOT_ being changed. > > >From the FILE+LINE+COL info the user can recover the info your patch > >> provides, but the reverse is generally not true. Of course, there is > >> the exception of when the source code has been changed or is missing or > >> somesuch, but I don't think we should consider those cases when > >> designing the featureset either, because here as well, this is expected > >> to be a fringe case. > > I would expect it to be quite common. > >From where I stand: > - If you don't have the source code any more, then you don't have anywhere > to fix the problem. > - If the source code has changed, then maybe the problem has already been > corrected (or modified) by that change, so there's not much point > debugging it any further. > So, why would you consider it to be common? Because people change source code, without necessarily compiling it straight away. Maybe you don't. Other people do. > What kind of scenario do you have in mind where this is sufficiently > common to be worth paying much attention to it? Wrong question. I've already explained enough, I believe backtraces and things like C-h v should work well IN ALL CASES. You don't. I'm asking you to accept this difference in view between us. > > We clearly differ in our views of what backtraces should do. > I don't know why you insist so much on backtraces. > I've wished for that info in many more cases than backtraces. That info will get displayed by anything using cl-prin1. > > Also, I think the backtrace code should be as robust as possible, you > > don't seem to. > I want it to be featureful, with a fallback for those rare cases when > that's not an option. You provided the fallback already in `debug-early`. But the information it currently prints is inadequate for lambda forms. That's what I've fixed, and it will be fixed in the "normal" backtrace code, too. You don't like it, for some reason. > > I will be working on putting this file and position information into the > > code. It will be tedious rather than difficult. > Why would it be tedious? It should be easier than what you did because > you don't need an extra arg to `lambda` and you don't need to > `defining-symbol` any more. It should make the change simpler. I'm not coding up your design decisions which I believe are misguided. Perhaps you should code up these things yourself if you think it's going to be so fascinating. Then we'll be able to compare my patch with yours. > >> > Which looks like you intend to strip it [debugging instrumentation] > >> > out, leaving interpreted code as a special case without the > >> > instrumentation. > >> Yes. > > OK, we have to disagree on this. For example typing d in edebug to get > > a backtrace should, in my view, show that info in the backtrace. > I don't find this particularly important. Other people, including me, do. > > Your way would make it unavailable. > You could tweak Edebug to add that info, thus keeping the change localized > to Edebug. I doubt it. > >> But as it currently stands, it comes at some costs: > >> - changing the syntax of `lambda`. > > lambda in the bulk of the sources remains unchanged. Only for very > > occasional cases has the syntax been enhanced. > Still, it changes the syntax of a very fundamental building block. > That's a pretty high cost in my book compared to the benefit it brings. You don't like my patch for some other reason. I think you're being unreasonably inflexible. As far as I can tell, you haven't tried it out yet, or looked at the code, beyond a superficial glance at a large diff. > If you want to do that, I'd rather you keep `lambda` as before and > macro-expand it to a new form that has the new syntax. There is no new syntax, as I keep telling you. > Part of the cost of your change here is that it prevents future changes > that might want to use a similar syntax for other purposes. > IOW it "eats up namespace", tho "namespace" is not quite the right word. I don't know what you're talking about here. > >> - changing the representation of functions (both bytecode and interpreted). > > Don't forget the native compiled, too! > That's more internal and it's currently not used for closures, so I find > this part of the cost negligible. > > Only the change to interpreted code is non-trivial. For the compiled > > code, there has simply been an extra field inserted at or near the end > > of the function structures. > For bytecode it's still an extra field (which we have to pay for every > closure we create) thus increasing memory use. Plus the incompatible > change of position of the interactive form (tho I find this less of an > problem). I think you're being thoroughly unrealistic here. RAM in a modern machine is measured in gigabytes, not kilobytes. There are around 36k DEFUNs/defuns/defmacros in Emacs. Even if all were simultaneously loaded into RAM, that would only be around a quarter of a megabyte of storage used up by my patch. If storage were really that critical, we would never have changed from 4-byte Lisp_Objects to 8-byte ones, something which will have hugely increased the storage used. The change in the interactive form in byte compiled functions isn't incompatible with anything that uses the proper interfaces. > Maybe in your tests, the increase is negligible, but remember: every > user will pay this tiny cost, and most of the users will never reap any > benefit from it, and those who do will only do very rarely. Developers will benefit. > It's a good change for us hard-core Emacs hackers, but it has to come > *very* cheap because the gain is really low for other users. It _is_ very cheap. > >> Storing the info in the docstring would fix the second and third point. > >> Using the FILE+LINE+COL info would fix the first. > > I don't know what you mean by "docstring". > Docstrings live in the `.elc` files. OK, you've got your own vocabulary on this point. To most people, a doc string is something abstract, which is created in *scratch* or a .el file, gets evaluated with, say C-x C-e, gets compiled by compile-defun, and gets native compiled, too, all the while remaining that same doc string. > > You could mean either in the ..elc/.eln file or in the function > > structure or both. I don't see docstring storage as a very good idea. > Probably because you think of it as a docstring only. > Think of it as "out of line storage" where we can keep introspection > data for which we don't want to pay *any* cost (other than disk space > use) in the normal execution of code (i.e. when calling the closure or > when creating the closure) such as: > - documentation > - human-readable arglist > - source code location > - debug info > - a copy of the source code > - ... Yes, I think of the "docstring" as the doc string. I don't think it a good idea to cram other things into it which aren't the doc string. > > It seems like a kludge, and would complicate Emacs's handling, much as > > the existing new code complicates it. > I see it as an opportunity to clean up this kludge. Go ahead, then. Then we can compare your version with mine. > Stefan -- Alan Mackenzie (Nuremberg, Germany).