summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/place.tl13
1 files changed, 13 insertions, 0 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl
index 7ef7f44d..5d17acb7 100644
--- a/share/txr/stdlib/place.tl
+++ b/share/txr/stdlib/place.tl
@@ -295,6 +295,19 @@
(with-delete-expander (deleter) place env
^(,deleter)))
+(defmacro lset (. places-source)
+ (let ((places (butlast places-source))
+ (source (last places-source))
+ (orig (gensym))
+ (iter (gensym)))
+ (unless places
+ (sys:eval-err "lset: require one or more places followed by expression"))
+ ^(let* ((,orig ,(car source))
+ (,iter ,orig))
+ ,*(butlast (mappend (ret ^((set ,@1 (car ,iter)) (set ,iter (cdr ,iter))))
+ places))
+ ,orig)))
+
(defmacro defplace (place-destructuring-args body-sym
(getter-sym setter-sym update-body) :
((ssetter-sym clobber-body))