unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Thuna <thuna.cing@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 72344@debbugs.gnu.org, spwhitton@spwhitton.name
Subject: bug#72344: [PATCH] Add a version of cl-once-only which handles lists of forms
Date: Thu, 15 Aug 2024 03:05:42 +0200	[thread overview]
Message-ID: <87ikw2ioih.fsf@gmail.com> (raw)
In-Reply-To: <86jzgj89ev.fsf@gnu.org>

>> >> +@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.





  reply	other threads:[~2024-08-15  1:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-28 21:17 bug#72344: [PATCH] Add a version of cl-once-only which handles lists of forms Thuna
2024-07-29  0:39 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-29 19:30   ` Thuna
2024-07-29 19:54     ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-29  7:09 ` Sean Whitton
2024-07-29 19:54   ` Thuna
2024-08-03  2:51     ` Sean Whitton
2024-08-03 22:40       ` Thuna
2024-08-06  1:41         ` Sean Whitton
2024-08-06  1:47           ` Sean Whitton
2024-08-09  5:44             ` Sean Whitton
2024-08-06 12:28           ` Thuna
2024-08-06 12:37             ` Sean Whitton
2024-08-13 21:17               ` Thuna
2024-08-13 21:36                 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-13 22:18                   ` Thuna
2024-08-13 22:57                     ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-14  0:01                     ` Sean Whitton
2024-08-14  0:05                 ` Sean Whitton
2024-08-14  2:21                   ` Thuna
2024-08-14  6:09                     ` Eli Zaretskii
2024-08-14 14:14                       ` Thuna
2024-08-14 14:29                         ` Eli Zaretskii
2024-08-15  1:05                           ` Thuna [this message]
2024-08-15  6:28                             ` Eli Zaretskii
2024-08-15 15:15                               ` Thuna
2024-08-15 16:20                                 ` Eli Zaretskii
2024-08-19 16:54                                   ` Richard Stallman
2024-08-15 12:38                         ` Sean Whitton
2024-08-15 15:02                           ` Thuna
2024-08-14  9:47                     ` Sean Whitton
2024-08-06 15:52           ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ikw2ioih.fsf@gmail.com \
    --to=thuna.cing@gmail.com \
    --cc=72344@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=spwhitton@spwhitton.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).