[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59333: [PATCH] Define macro dlet*
From: |
Jean Louis |
Subject: |
bug#59333: [PATCH] Define macro dlet* |
Date: |
Sat, 19 Nov 2022 07:47:16 +0300 |
User-agent: |
Mutt/2.2.7+37 (a90f69b) (2022-09-02) |
* 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/