unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Sean Whitton <spwhitton@spwhitton.name>
Cc: emacs-devel@gnu.org
Subject: Re: master 2e9111813b: Add two classic Common Lisp macro-writing macros
Date: Tue, 12 Apr 2022 22:25:43 +0300	[thread overview]
Message-ID: <83k0bu3xzc.fsf@gnu.org> (raw)
In-Reply-To: <8735iicfcd.fsf@melete.silentflame.com> (message from Sean Whitton on Tue, 12 Apr 2022 11:43:30 -0700)

> From: Sean Whitton <spwhitton@spwhitton.name>
> Date: Tue, 12 Apr 2022 11:43:30 -0700
> 
> Here's my docs patch if anyone has any comments.

Thanks for writing the documentation.

> +@defmac cl-with-gensyms names body@dots{}

Shouldn't @dots{} follow NAMES?  There's just one BODY, but any
number of NAMES, right?

> +This macro expands to code that executes @var{body} with each of the
> +variables in @var{names} bound to a fresh uninterned symbol or
> +``gensym''.

Instead of "or" I suggest to say "a.k.a.@: @dfn{gensym}" (and add a
@cindex entry for "gensym", as usual with any term in @dfn).

> +@defmac cl-once-only ((name form)@dots{}) body@dots{}
> +This macro is primarily to help the macro programmer ensure that forms
> +supplied by the user of the macro are evaluated just once by its
> +expansion even though the result of evaluating the form is to occur
> +more than once.  Less often, this macro is used to ensure that forms
> +supplied by the macro programmer are evaluated just once.
> +
> +Each @var{name} is a variable which can be used to refer to the result
> +of evaluating @var{form} in @var{body}.  @code{cl-once-only} binds
> +each @var{name} to a fresh uninterned symbol during the evaluation of
> +@var{body}.

My recommendation is always to try to name parameters after their
roles.  In this case, I'd use VAR or VARIABLE instead of the less
specific NAME.  Then you could make the text shorter and thus clearer:

  Each @var{variable} can be used to refer to the result of evaluating
  @var{form} in @var{body}.  @code{cl-once-only} binds each
  @var{variable} to a fresh uninterned symbol...

(And why not use "gensym" instead of the wordier "uninterned symbol"?
that's why you introduced that terminology, right?)

>            Then, @code{cl-once-only} wraps the final expansion in
> +code to evaluate each @var{form} and bind it to the corresponding
> +uninterned symbol.

How can a form be bound to a symbol?

> +In a call like @code{(my-list (pop foo) ...)} the intermediate binding
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Long stretches of @code which have embedded whitespace, like that one
above, should be  wrapped in @w{..}, to prevent them from being broken
between two lines.

Also, why a literal "..." instead of @dots{}?

> ++++
> +** New macro-writing macros, 'cl-with-gensyms' and 'cl-once-only'.

I suggest to add here a pointer to the node in the manual where they
are described, since this entry tells nothing about that to someone
who doesn't already know CL well enough.

Thanks.



  reply	other threads:[~2022-04-12 19:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <164974332528.14217.12591424007013368601@vcs2.savannah.gnu.org>
     [not found] ` <20220412060205.8B446C01687@vcs2.savannah.gnu.org>
2022-04-12  6:15   ` master 2e9111813b: Add two classic Common Lisp macro-writing macros Sean Whitton
2022-04-12  7:14     ` Stefan Monnier
2022-04-12 15:57       ` Sean Whitton
2022-04-12 16:22         ` Stefan Monnier
2022-04-12  6:42   ` Po Lu
2022-04-12 18:43     ` Sean Whitton
2022-04-12 19:25       ` Eli Zaretskii [this message]
2022-04-13  5:48         ` Sean Whitton
2022-04-13 12:35           ` Eli Zaretskii
2022-04-13 19:46           ` Johann Klähn
2022-04-13 23:16             ` Sean Whitton
2022-04-13  3:58     ` Richard Stallman
2022-04-13  5:08       ` Sean Whitton
2022-04-14  2:56         ` Richard Stallman
2022-04-14  5:14           ` Sean Whitton
2022-04-14 12:06             ` [External] : " Drew Adams
2022-04-15  3:59             ` Richard Stallman
2022-04-15  6:14               ` Eli Zaretskii
2022-04-17  4:09                 ` Richard Stallman
2022-04-17  1:57               ` Michael Heerdegen
2022-04-18  2:41                 ` Richard Stallman
2022-04-18  5:18                   ` Eli Zaretskii
2022-04-19  3:49                     ` Richard Stallman
2022-04-12  8:46   ` Lars Ingebrigtsen
2022-04-12 15:52     ` Sean Whitton
2022-04-12 15:59       ` Lars Ingebrigtsen
2022-04-13  9:21   ` Philip Kaludercic
2022-04-13 15:14     ` Stefan Monnier

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=83k0bu3xzc.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@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).