summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisplib.c2
-rw-r--r--share/txr/stdlib/place.tl6
-rw-r--r--txr.125
3 files changed, 32 insertions, 1 deletions
diff --git a/lisplib.c b/lisplib.c
index 49e4841e..e1b2a9ca 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -62,7 +62,7 @@ static val place_set_entries(val dlt, val fun)
lit("get-update-expander"), lit("get-clobber-expander"),
lit("get-delete-expander"),
lit("place-form-p"),
- lit("rlet"), lit("slet"), lit("with-gensyms"),
+ lit("rlet"), lit("slet"), lit("alet"), lit("with-gensyms"),
lit("call-update-expander"), lit("call-clobber-expander"),
lit("call-delete-expander)"),
lit("with-update-expander"), lit("with-clobber-expander"),
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl
index 74b5b01d..4d5e63dd 100644
--- a/share/txr/stdlib/place.tl
+++ b/share/txr/stdlib/place.tl
@@ -133,6 +133,12 @@
(defmacro slet (bindings :env e . body)
(sys:r-s-let-expander bindings body e [orf constantp bindable]))
+(defmacro alet (bindings :env e . body)
+ (let ((exp-bindings (mapcar (aret ^(,@1 ,(macroexpand @2 e))) bindings)))
+ ^(,(if [all exp-bindings [orf constantp bindable] second]
+ 'symacrolet 'let)
+ ,exp-bindings ,*body)))
+
(defmacro with-gensyms (syms . body)
^(let ,(zip syms (repeat '((gensym)))) ,*body))
diff --git a/txr.1 b/txr.1
index d4a42a72..06d4e775 100644
--- a/txr.1
+++ b/txr.1
@@ -27812,6 +27812,31 @@ to symbol macros. In addition, unlike
also reduces to symbol macros those bindings which
are initialized by symbol expressions (values of variables).
+.coNP Macro @ alet
+.synb
+.mets (alet >> ({( sym << init-form )}*) << body-form *)
+.syne
+.desc
+The macro
+.code alet
+("atomic" or "all") is a stronger form of the
+.code slet
+macro. The transformation of any of the bindings to symbol macros takes place
+under the same conditions as under
+.codn slet .
+However,
+.code alet
+imposes the restriction that all the bindings must be transformed
+to symbol macros, or not at all.
+
+The
+.code alet
+macro can be used to avoid introducing temporary variables in situations when
+it is suspected that the initializing forms for the variables have side
+effects through which they affect each others' evaluations. The suspicion is
+lifted if the all initializing forms (after expansion) are constants, or
+accesses to symbols.
+
.coNP Macro @ define-accessor
.synb
.mets (define-accessor < get-function << set-function )