From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72344: [PATCH] Add a version of cl-once-only which handles lists of forms Date: Thu, 15 Aug 2024 09:28:35 +0300 Message-ID: <867cci8fl8.fsf@gnu.org> References: <87y15l1aj8.fsf@gmail.com> <8734nsk72i.fsf@melete.silentflame.com> <87plqw0y9j.fsf@gmail.com> <87ikwi5neo.fsf@melete.silentflame.com> <871q35mdrd.fsf@gmail.com> <871q321l7d.fsf@melete.silentflame.com> <874j7xzvgx.fsf@gmail.com> <87r0b1su7p.fsf@melete.silentflame.com> <874j7o2kcq.fsf@gmail.com> <87zfpg3r4q.fsf@melete.silentflame.com> <87v80326ab.fsf@gmail.com> <86mslffxfj.fsf@gnu.org> <87o75vi43v.fsf@gmail.com> <86jzgj89ev.fsf@gnu.org> <87ikw2ioih.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25300"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72344@debbugs.gnu.org, spwhitton@spwhitton.name To: Thuna Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 15 08:29:39 2024 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 1seTzN-0006Rq-US for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Aug 2024 08:29:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1seTzE-0007y5-TU; Thu, 15 Aug 2024 02:29:28 -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 1seTzD-0007xg-8L for bug-gnu-emacs@gnu.org; Thu, 15 Aug 2024 02:29:27 -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 1seTzC-0003dL-Vx for bug-gnu-emacs@gnu.org; Thu, 15 Aug 2024 02:29:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=tLmzK65trtMKoEmGTd/meDlNsJ47hh8QTKZWoW1tQUc=; b=gX3qET54h5SIzYSteji3RItOuERbMECYLgmWJuQx89bKyVR9PAfJoTKad+4SE38kwobYYQOR1QTHlE6liHjl1w1QPzGzcKgvMO98rSRVxv4t/lyPwrrgPk7YpBXWcTckV5S3UQEDqoTcYowXVcV4YKiOsBfkhXgviz5Z8hjGdbiggMIViSywdxQ1aDRXwKa2F1+66zAdBMRp6WTYIBCzJFmBU8t3EUOaXXQp6uFCSGNzZKosZKlFsiPdqY2i3okuir66xNnDXWuIrKDuXszs7F/U1kJgY7iThl29HZx/hJ4kb2zAGQOh6JPwxqaeKYdeqAP0cKU5zeYCWTUIHzQzow==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1seTzm-0002Gq-O8 for bug-gnu-emacs@gnu.org; Thu, 15 Aug 2024 02:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Aug 2024 06:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72344 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 72344-submit@debbugs.gnu.org id=B72344.17237033648655 (code B ref 72344); Thu, 15 Aug 2024 06:30:02 +0000 Original-Received: (at 72344) by debbugs.gnu.org; 15 Aug 2024 06:29:24 +0000 Original-Received: from localhost ([127.0.0.1]:48203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1seTz9-0002FW-Hn for submit@debbugs.gnu.org; Thu, 15 Aug 2024 02:29:23 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:34780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1seTz7-0002FJ-J6 for 72344@debbugs.gnu.org; Thu, 15 Aug 2024 02:29:22 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1seTyR-0003Zx-Cm; Thu, 15 Aug 2024 02:28:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=tLmzK65trtMKoEmGTd/meDlNsJ47hh8QTKZWoW1tQUc=; b=RTdagbceJIAz Lfz+kWTA1xJoQL6oTlFfO+9PoGNiJlI3x8yqcLvJgUeIcKJTr6RGoVzTvRPzcG8sB6tOQemqFeI33 E6l91nRZgHLCrOxLOy+mU5Nx3pZE7g4woj7eeBnUo1Rtvm5IkBO0QzAEtC2iH6AieZamCpy+0hojT bM7yOnVVW9mjPBLKh5OsY+Qh8Jszz/77oosEWFNJXzgjIlC7OoVwvlWBnxDiZpjk3bR6pIW/vzmQc 4TGgOY5zrOLU62DBpxP6bmMQk6qwn3irzfGuQFZf/dcwRMBHJpvPPFdriOV1+FOqfXTJOBW3Z4Gg7 kxduR+ay3j8Y33x4L2ZWSQ==; In-Reply-To: <87ikw2ioih.fsf@gmail.com> (message from Thuna on Thu, 15 Aug 2024 03:05:42 +0200) 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:290162 Archived-At: > From: Thuna > Cc: spwhitton@spwhitton.name, 72344@debbugs.gnu.org > Date: Thu, 15 Aug 2024 03:05:42 +0200 > > >> >> +@defmac cl-once-only* (variable forms) body > >> > ^^^^^ > >> > Shouldn't this be "forms@dots{}"? or maybe "form@dots{}"? > >> > >> No, it is "forms", which is evaluated to obtain a list of forms, each of > >> which is individually analogous to "form" in `cl-once-only' as used in > >> the info. Maybe I have failed to communicate this properly. Would an > >> example like > >> > >> (cl-defmacro foo ((&rest optforms) body &rest forms) > >> (cl-once-only* (all-forms (append optforms forms)) ...)) > >> > >> help? > > > > Not really. What is missing is the explicit statement that FORMS is > > evaluated to yield a list of forms. (Btw, why is it called "FORMS", > > plural, when it is actually a single form that yields a list of forms > > only when evaluated?). The text you wrote: > > > > +Each element of @var{variable} may be used to refer to the result of > > +evaluating the corresponding form in @var{forms} within @var{body}. > > > > doesn't mention that FORMS is evaluated, and makes it sound like FORMS > > includes several forms to begin with ("corresponding form in FORMS"). > > > > This is in direct contradiction with what you explained now, and > > therefore this text needs to be amended. > > Sorry, this whole thing is a bit confusing due to the layers involved, so let > me try to explain it again and also try to explain my rationale. Maybe it > will answer some of your questions and/or clear up some miscommunication. > > There are three evaluation times here: > 1. [us] Evaluation of cl-once-only* while macroexpanding (defmacro foo ...) > 2. [macro author] Evaluation of foo while macroexpanding (foo ...) > 3. [macro user] Evaluation of the macroexpansion of (foo ...) > > During 1, FORMS is a single form(1) and VARIABLE is a (non-constant) > symbol(1). > > During 2, this form(1) is evaluated to obtain a list of forms(2), and > symbol(1) is bound to a list of symbols(2) within BODY. > > During 3, each symbol(2) is bound to the result of evaluating the > corresponding form(2). > > The macro author interfaces with `cl-once-only*' by passing to it > - a list of forms(2) which will be evaluated during 3. > - a symbol(1) which, during 2, will be bound to a list of symbols(2), each of > which will hold the value of the corresponding form(2) during 3. > so from their perspective FORMS is in fact a list of forms. > > While I was writing I was trying to use terms the way a macro author would > conceptualize, so the name "FORMS" follows from it being a list of forms(2) > during 2. > > Also, again from the macro author's perspective, > > corresponding form in FORMS > > it ... is evaluated to obtain a list of forms > > FORMS includes several forms to begin with > ends up reading as > > corresponding form(2) in [the list of forms(2)] > > [form(1)] ... is evaluated to obtain [the] list of forms(2) > > [the list of forms(2)] includes several forms to begin with > which isn't a contradiction. I suspect you (understandably) read every `form' > as form(1), under which interpretation it would indeed be a contradiction. > > I agree that it needs to be mentioned that FORMS is evaluated (during 2). > I'll probably need to rewrite this thing again, so I'll try to put it in then. Sorry, I'm now completely confused and bewildered. Earlier you said 'it is "forms", which is evaluated to obtain a list of forms', now you seem to be saying that this evaluation is not relevant to the macro (i.e. is done before the macro is called)? Anyway, what I'm looking for is not _my_ understanding, but some text for the manual and the doc strings which will explain this to the reader. So maybe suggest text that you think is both accurate and not supposed to confuse, and let's take it from there.