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#65620: void function edebug-after Date: Fri, 1 Sep 2023 09:23:35 +0000 Message-ID: References: <87ledsku08.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37848"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Michael Heerdegen , acm@muc.de, 65620@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 01 11:24:41 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 1qc0OK-0009XA-Sx for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Sep 2023 11:24:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qc0Nh-0006Fr-8W; Fri, 01 Sep 2023 05:23:57 -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 1qc0Ne-0006Cf-Ge for bug-gnu-emacs@gnu.org; Fri, 01 Sep 2023 05:23:54 -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 1qc0Ne-0006xv-0F for bug-gnu-emacs@gnu.org; Fri, 01 Sep 2023 05:23:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qc0Nl-0008Cl-QK for bug-gnu-emacs@gnu.org; Fri, 01 Sep 2023 05:24:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Sep 2023 09:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65620 X-GNU-PR-Package: emacs Original-Received: via spool by 65620-submit@debbugs.gnu.org id=B65620.169356023831530 (code B ref 65620); Fri, 01 Sep 2023 09:24:01 +0000 Original-Received: (at 65620) by debbugs.gnu.org; 1 Sep 2023 09:23:58 +0000 Original-Received: from localhost ([127.0.0.1]:59860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qc0Nh-0008CT-Cs for submit@debbugs.gnu.org; Fri, 01 Sep 2023 05:23:57 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:64659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qc0Nd-0008CC-Kc for 65620@debbugs.gnu.org; Fri, 01 Sep 2023 05:23:55 -0400 Original-Received: (qmail 27966 invoked by uid 3782); 1 Sep 2023 11:23:37 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=muc.de; i=@muc.de; q=dns/txt; s=default; t=1693560217; h=date : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to : from : from; bh=+E03Z3uD017RkyjYW/PW2idHbSC0Id9wqmS5gwemhxk=; b=HGv/Ucc5E+Q4h191ST2R6zcsXQkmSw0n+9ZSxX3h+dtHVB+syQOxRNZZMfo/O1jd41Eey 3rBH91cxKw9GZ1eHW7twbdEHBp3UrZKtl3JIe065ByupgtnIj0uCp640H+3D6GMLUuH7oaP uU3Pr9rmPY0dUNAdoM/4+aHFmQpZsdnFLIrgXlovBJR6W6OOCFe3qxvrERgpeihms+5Aurs nyT0P5IQ0aYAY0mmIzAiy2Yx+5Pd/XdLZ+XPk5ktQUw3/j1EW91fMJMO1B5ukDUR/AVELMe v6C5hkWS/q3A9Q29+EDzSgKMKuwkfi+6+nauxIyYnBslH6ttGtNAlG0gMiCg== Original-Received: from acm.muc.de (pd953a051.dip0.t-ipconnect.de [217.83.160.81]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 01 Sep 2023 11:23:36 +0200 Original-Received: (qmail 16310 invoked by uid 1000); 1 Sep 2023 09:23:35 -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:268872 Archived-At: Hallo, Gerd, Grüß aus Nürnberg! On Thu, Aug 31, 2023 at 16:41:21 +0200, Gerd Möllmann wrote: > Alan Mackenzie writes: > Hallo Alan, Grüße nach Nürnberg :-). > > On Thu, Aug 31, 2023 at 09:55:18 +0200, Gerd Möllmann wrote: > >> Michael Heerdegen writes: > >> > Alan Mackenzie writes: > >> >> (defmacro hash-if (condition then-form &rest else-forms) > >> >> "A conditional compilation macro analogous to C's #if. > >> >> Evaluate CONDITION at macro-expansion time. If it is non-nil, > >> >> expand the macro to THEN-FORM. Otherwise expand it to ELSE-FORMS > >> >> enclosed in a `progn' form. ELSE-FORMS may be empty." > >> >> (declare (indent 2) > >> >> (debug (form sexp &rest sexp))) > >> >> (if (eval condition lexical-binding) > >> >> then-form > >> >> (cons 'progn else-forms))) > >> > Dunno if someone is able to fix this (I'm not). Until then using > >> > `def-form` `or `sexp` instead of `form` works in a better way (the > >> > former edebugs CONDITION when instrumenting, the latter would omit > >> > edebugging the CONDITION entirely). > >> > Anyway, the key point in the above example is that macroexpanding (while > >> > instrumenting) combined with the `eval' call seems to lead to the > >> > evaluation of instrumented code outside of an Edebug session when > >> > CONDITION is instrumented using `form`. `eval-when-compile' uses > >> > `def-form` for example - I guess using `form` in this case doesn't work > >> > as one might expect. > >> I think what's happening here is like this: > >> By using 'form' for condition, we're telling edebug to instruments it. > >> That is, the argument eval sees when foo is instrumented is whatever > >> edebug wraps around the condition (< ...), and that contains the > >> eval-after. Using sexp for the condition doesn't instrument the condition. > > Or, put a different way, edebug has instrumented CONDITION, then tries to > > evaluate this. This fails because there is no call to > > edebug-make-enter-wrapper around the thing, which would defalias > > edebug-after and edebug-before, and set up several lists that edebug > > needs. > I think that's correct, but I wouldn't say Edebug evaluates CONDITION, > but we probably mean the same thing: CONDITION is instrumented and > HASH-IF then gets that as argument when FOO is macroexpanded. Then the > execution of HASH-IF tries to evaluate the instrumented condition etc. I think I've got it, now. Considering that hash-if evaluates CONDITION, it is an error for edebug to evaluate CONDITION as an argument first; there would be a sort of "double evaluation". So I need to use sexp rather than form in the edebug spec, like Michael and you have been telling me all along. :-) > >> One can follow that in the backtrace. > >> So, I guess there's nothing to fix here. > > I don't think I agree. eval (and probably apply and funcall and its > > variants) should somehow generate an "optional" edebug-make-enter-wrapper > > around them. This is currently not done. > That would be one way. On the other hand, the instrumentation of > CONDITION is actually kind of pointless, because nothing will be > left of it in the fully macroexpanded FOO. So, one cannot step through > CONDITION with Edebug anyway. Yes. This is a shame, since it would be nice to step through CONDITION, particularly if it is complicated. I think a better way of handling this would be to have a "base function" for edebug-after (and for edebug-before), as opposed to the nil that each of these currently has. These functions would throw an error asking the user to check the edebug spec. Something like (untested): (defun edebug-after (before-index after-index form) "Version of `edebug-after' to call when edebug is not yet set up. This function gets temporarily replaced by a real function when edebug becomes active." (error "Invalid call to `edebug-after' for %S: Is your debug spec \ correct?" form)) .. What do you think? -- Alan Mackenzie (Nuremberg, Germany).