summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-28 06:15:18 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-03-28 06:15:18 -0700
commite6e2346e5cae8dd1a0ac6ad4676fd2ae1ad4ce98 (patch)
treee2f48f85c49b46267b368cb91d91c3f6b931cf0a /share
parent70203c5cdab161f2d12756ff382035efbbaef421 (diff)
downloadtxr-e6e2346e5cae8dd1a0ac6ad4676fd2ae1ad4ce98.tar.gz
txr-e6e2346e5cae8dd1a0ac6ad4676fd2ae1ad4ce98.tar.bz2
txr-e6e2346e5cae8dd1a0ac6ad4676fd2ae1ad4ce98.zip
New macro: lset.
* lisplib.c (place_set_entries): Added "lset" to autoload list. * share/txr/stdlib/place.tl (lset): New macro. * txr.1: Documented lset.
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))