unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59333: [PATCH] Define macro dlet*
@ 2022-11-17  7:13 daanturo
  2022-11-17  7:25 ` Eli Zaretskii
  2022-11-19  4:47 ` Jean Louis
  0 siblings, 2 replies; 10+ messages in thread
From: daanturo @ 2022-11-17  7:13 UTC (permalink / raw)
  To: 59333

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

--=-=-=
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.

I would rather prefer b72f88518b89560accf740a4548368863e6238e0 be
reverted, though. But maybe that's fine if the majority of maintainers
agree with that change. But please mention similar breakages more
universally.



In GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.34, cairo version 1.17.6) of 2022-11-13 built on dan-laptop
Repository revision: b806e8a8a2c7d01a18f11e6582961c42a9eecc01
Repository branch: makepkg
System Description: Arch Linux

Configured using:
'configure --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
--localstatedir=/var
'--program-transform-name=s/\([ec]tags\)/\1.emacs/' --with-json
--with-libsystemd --with-mailutils --with-modules --with-pgtk
--without-xaw3d --with-sound=alsa --with-xinput2 --with-xwidgets
--without-compress-install --with-native-compilation=aot
--with-tree-sitter 'CFLAGS=-march=native -O2 -pipe -fno-plt
-fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection'
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

--=-=-=--

-- 
Daanturo.

[-- Attachment #2: 0001-Define-macro-dlet-star.patch --]
[-- Type: text/x-patch, Size: 2801 bytes --]

From cf4dba3899eef0a88bf4032bec5cf45c56a77077 Mon Sep 17 00:00:00 2001
From: Daanturo <daanturo@gmail.com>
Date: Thu, 17 Nov 2022 13:57:20 +0700
Subject: [PATCH] Define macro dlet*

* lisp/subr.el: implementation.
* doc/lispref/variables.texi: documentation.
* etc/NEWS: announce it, also add dlet's non-backward compatible
breakage.
---
 doc/lispref/variables.texi |  8 ++++++++
 etc/NEWS                   | 10 ++++++++++
 lisp/subr.el               |  8 ++++++++
 3 files changed, 26 insertions(+)

diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 7206f2acd2..c574ffaf09 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -303,6 +303,14 @@ Binding}), but it's impractical to @code{defvar} these variables.
 the forms, and then make the variables non-special again.
 @end defspec
 
+@defspec dlet* (bindings@dots{}) forms@dots{}
+This form is like @code{dlet}, but each valueform can refer to the
+symbols already bound previously, like what @code{let*} is to
+@code{let} (actually this is Emacs 28's old @code{dlet}, as from Emacs
+29 it no longer let bindings refer to the preceding symbols in this
+same form).
+@end defspec
+
 @defspec named-let name bindings &rest body
 This special form is a looping construct inspired from the
 Scheme language.  It is similar to @code{let}: It binds the variables in
diff --git a/etc/NEWS b/etc/NEWS
index 0b8f4539f9..1e9b1ce279 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2913,6 +2913,10 @@ when visiting JSON files.
 \f
 * Incompatible Lisp Changes in Emacs 29.1
 
++++
+** dlet now uses let internally instead of let*.
+---
+
 +++
 ** 'format-prompt' now uses 'substitute-command-keys'.
 This means that both the prompt and 'minibuffer-default-prompt-format'
@@ -3269,6 +3273,12 @@ The following generalized variables have been made obsolete:
 \f
 * Lisp Changes in Emacs 29.1
 
+
++++
+** New macro 'dlet*'.
+Like what 'let*' is to 'let', functionally identical to the old 'dlet'
+in Emacs 28.
+
 +++
 ** Interpreted closures are "safe for space".
 As was already the case for byte-compiled closures, instead of capturing
diff --git a/lisp/subr.el b/lisp/subr.el
index 6b83196d05..ddc48b554e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2155,6 +2155,14 @@ all symbols are bound before any of the VALUEFORMs are evalled."
                binders)
      (let ,binders ,@body)))
 
+(defmacro dlet* (binders &rest body)
+  "Like `let*' but using dynamic scoping."
+  (declare (indent 1) (debug let))
+  `(let (_)
+     ,@(mapcar (lambda (binder)
+                 `(defvar ,(if (consp binder) (car binder) binder)))
+               binders)
+     (let ,binders ,@body)))
 
 (defmacro with-wrapper-hook (hook args &rest body)
   "Run BODY, using wrapper functions from HOOK with additional ARGS.
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-25  0:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-11-19  5:29   ` daanturo

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).