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#52147: Eager macro-expansion is not performed in `eval-and-compile' functions Date: Sat, 15 Jan 2022 10:09:36 -0500 Message-ID: References: <87czmk7etf.fsf@web.de> <87zgpnuft8.fsf@gnus.org> <8735nen590.fsf@web.de> <87pmotta9j.fsf@gnus.org> 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="39402"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Michael Heerdegen , 52147@debbugs.gnu.org, Paul Pogonyshev To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 15 16:10:58 2022 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 1n8khl-000A6H-Bk for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 15 Jan 2022 16:10:57 +0100 Original-Received: from localhost ([::1]:46364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8khj-0002EH-SN for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 15 Jan 2022 10:10:55 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:49970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8kgt-0002De-BN for bug-gnu-emacs@gnu.org; Sat, 15 Jan 2022 10:10:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8kgs-0003TQ-Eg for bug-gnu-emacs@gnu.org; Sat, 15 Jan 2022 10:10:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8kgs-0004VC-Ai for bug-gnu-emacs@gnu.org; Sat, 15 Jan 2022 10:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Jan 2022 15:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52147 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 52147-submit@debbugs.gnu.org id=B52147.164225938717278 (code B ref 52147); Sat, 15 Jan 2022 15:10:02 +0000 Original-Received: (at 52147) by debbugs.gnu.org; 15 Jan 2022 15:09:47 +0000 Original-Received: from localhost ([127.0.0.1]:41495 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8kgd-0004Uc-37 for submit@debbugs.gnu.org; Sat, 15 Jan 2022 10:09:47 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:15082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8kga-0004UM-QU for 52147@debbugs.gnu.org; Sat, 15 Jan 2022 10:09:45 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B27DE1001AC; Sat, 15 Jan 2022 10:09:38 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 40B50100120; Sat, 15 Jan 2022 10:09:37 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1642259377; bh=m4bUx8stIyef7RMgRtknlYoNSETbf6NX4Hwm6ryZm/0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=EJDnsxj7P4eIO+pM1mylHSB33ZTfEqYavzaEeB/5dlCEFGvz9//130aoU/CKBOBWy DnQMbDTOeEpUWgpFb+QP2FUDFFJzoUCGK/K/Bz2txwNxHX3PtMZowk4xn0XNaxkxJc fUUtwuwJGJl0l5RSS11UWwRbmH3cWiObp7veRu/w/9R0wHRcnL5ZrNh6o3YiLOMekX 6lhY3elt/fyvd+XxemUa+iL8DklQHn+y7i7W1MVm9sq9Os0TB8cSMys7mTdNw7Tekr VMpCDiO+dXS0flwZU0gKzlHIzYoPS+VdvhfYEWzezjYUJhplvOxcIC97W/niQvYbE/ NEFCJB3uX0bfw== Original-Received: from pastel (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 050A8120783; Sat, 15 Jan 2022 10:09:36 -0500 (EST) In-Reply-To: <87pmotta9j.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 15 Jan 2022 14:10:32 +0100") 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" Xref: news.gmane.io gmane.emacs.bugs:224315 Archived-At: >>> We usually don't stress a lot about the performance of interpreted >>> (i.e., uncompiled) code. Indeed. >> Well we do, a bit, >> >> (info "(elisp) How Programs Do Loading") >> >> says that loading a file performs eager macro expansion and that does >> speed up the resulting code. `eval', `eval-when-compile' and >> `eval-and-compile' don't perform eager macro expansion. I don't know to >> what degree this is on purpose. But if a macro is defined later in the >> file or in another file that has not yet been loaded this may not be >> possible anyway. > > It sounds to me like things are basically working as designed. > > Perhaps Stefan has some comments; added to the CCs. AFAIK the exact time of macro expansion is left underspecified on purpose. Whether eager-macroexpansion is used or not should be an implementation detail. A piece of code which relies on macro-expansion being done lazily is a bug, AFAIC. Usually those bugs become apparent when byte-compiling the file (where macro-expansion is necessarily eager), except for those cases that occur during bootstrap. Both `eval-when-compile` and `eval-and-compile` currently defer to `eval`, but they should arguably do the macro-expansion eagerly, indeed. `eval` currently doesn't use eager macro-expansion because I haven't done the work needed to check/ensure that the resulting potential slowdown is negligible. But I think `eval` should also eagerly macro-expand its argument. Stefan