unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: daanturo <daanturo@gmail.com>
Cc: 59333@debbugs.gnu.org
Subject: bug#59333: [PATCH] Define macro dlet*
Date: Sat, 19 Nov 2022 07:47:16 +0300	[thread overview]
Message-ID: <Y3hf1OAzc6Gi/VtQ@protected.localdomain> (raw)
In-Reply-To: <0e8ca5ce-a413-0dd0-c62e-647d19953a3b@gmail.com>

* daanturo <daanturo@gmail.com> [2022-11-17 10:16]:
> --=-=-=
> Content-Type: text/plain
> 
> Tags: patch
> 
> 
> The dlet breakage comes as much surprise to me. There's not even a
> single entry in NEWS that mentions it.

If I remember well, `dlet' was working just fine (as in the sense of
dlet*), and then because it was changed and made `dlet' behave not in
the sense of `dlet*', it did not work any more for me, so I have
renamed the old dlet, to my private function `rcd-dlet' to fix it's
behavior when developers changed the last line.

The last line of `dlet' is now:  (let ,binders ,@body))) while I need
it to be as below:      (let* ,binders ,@body)))

(defmacro rcd-dlet (binders &rest body)
  "Like `let*' but using dynamic scoping.

Argument BINDERS behaves similarly like `let' with the difference
that variables become global even under lexical scope.

Optional argument BODY will be executed."
  (declare (indent 1) (debug let))
  ;; (defvar FOO) only affects the current scope, but in order for
  ;; this not to affect code after the main `let' we need to create a new scope,
  ;; which is what the surrounding `let' is for.
  ;; FIXME: (let () ...) currently doesn't actually create a new scope,
  ;; which is why we use (let (_) ...).
  `(let (_)
     ,@(mapcar (lambda (binder)
                 `(defvar ,(if (consp binder) (car binder) binder)))
               binders)
     (let* ,binders ,@body)))


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/





  parent reply	other threads:[~2022-11-19  4:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  7:13 bug#59333: [PATCH] Define macro dlet* daanturo
2022-11-17  7:25 ` Eli Zaretskii
2022-11-17  7:40   ` Daan Ro
2022-11-19  4:37     ` Jean Louis
2022-11-17 13:22   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-17 13:36     ` Mattias Engdegård
2022-11-25  0:14       ` Stefan Kangas
2022-11-19  4:28   ` Jean Louis
2022-11-19  4:47 ` Jean Louis [this message]
2022-11-19  5:29   ` daanturo

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=Y3hf1OAzc6Gi/VtQ@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=59333@debbugs.gnu.org \
    --cc=daanturo@gmail.com \
    /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).