From: Jean Louis <bugs@gnu.support>
To: Tassilo Horn <tsdh@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: master b72f885: Make dlet work like let, not let*
Date: Tue, 21 Sep 2021 10:17:39 +0300 [thread overview]
Message-ID: <YUmHE4FOyAmaJnew@protected.localdomain> (raw)
In-Reply-To: <878rzqtopk.fsf@gnu.org>
* Tassilo Horn <tsdh@gnu.org> [2021-09-21 09:42]:
> where the binding of languages_extension and area_id can access the new
> value of the defvar wrs::variables (because of let*) but
> languages_extension and area_id are only bound lexically (because they
> are not defvar-ed and should not because of their missing prefix)
> meaning they are bound only in the body of this `let*' (lexically!) but
> not in `do-stuff' when it is called in this `let*'s body. So for those,
> you really need dlet. Assuming that area_id never depends on the value
> of languages_extension etc, you probably can use
>
> (defvar wrs::variables nil)
>
> (let ((wrs::variables ...))
> (dlet ((languages_extension (gethash "languages_extension" wrs::variables))
> (area_id (gethash "area_id" wrs::variables)))
> (do-stuff)))
Thanks, those are good pointers.
Though I did not explain everything. `dlet' is (was) used on my side
to interpolate bunch of information. Variables are also fetched from
the database and interpolated. In general there are too many issues
that I would need to refactor and think about it now, which is not
necessary. This gave me enough time waste.
My temporary personal solution is simply to bring it back how it was
and rename the macro to my own.
(defmacro rcd-dlet (binders &rest body)
"Like `let*' but using dynamic scoping."
(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)))
As a side note, the advise for variables to be first `defvar-ed' if
they are to be used in `let*' is not practical. It increases work, it
does not lessen the work.
You know when you start creating `let*' variables you don't want to
think much, just do it. Now I am supposed to make 50-100 `defvar-ed'
variables.
Instead I will just use the modified macro for myself, which does what
`dlet' was doing before August 1st 2021.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
next prev parent reply other threads:[~2021-09-21 7:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-01 16:10 master b72f885: Make dlet work like let, not let* Eli Zaretskii
2021-08-03 13:03 ` Mattias Engdegård
2021-08-03 13:33 ` Eli Zaretskii
2021-08-03 15:21 ` Mattias Engdegård
2021-08-03 15:58 ` Eli Zaretskii
2021-08-03 17:19 ` Stefan Monnier
2021-08-03 17:50 ` Eli Zaretskii
2021-08-03 18:50 ` Stefan Monnier
2021-08-04 11:27 ` Eli Zaretskii
2021-08-04 11:35 ` Lars Ingebrigtsen
2021-08-04 11:46 ` Mattias Engdegård
2021-08-04 12:16 ` Eli Zaretskii
2021-08-04 12:48 ` Mattias Engdegård
2021-08-04 12:15 ` Eli Zaretskii
2021-08-04 3:09 ` Michael Heerdegen
2021-08-04 11:40 ` Eli Zaretskii
2021-09-20 17:08 ` Jean Louis
2021-09-20 17:02 ` Jean Louis
2021-09-20 16:56 ` Jean Louis
2021-09-20 19:16 ` Tassilo Horn
2021-09-21 4:19 ` Jean Louis
2021-09-21 6:31 ` Tassilo Horn
2021-09-21 7:17 ` Jean Louis [this message]
2021-09-21 7:50 ` Tassilo Horn
2021-09-21 9:31 ` Jean Louis
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YUmHE4FOyAmaJnew@protected.localdomain \
--to=bugs@gnu.support \
--cc=emacs-devel@gnu.org \
--cc=tsdh@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.