summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-06-17 21:43:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-06-17 21:43:04 -0700
commitbf643381806466038ed913b084bf20df3fc567e5 (patch)
tree0230764153bcbdc066c2453a7cfdbdbbddd9de37
parent478a2e7244891cdb2349f5fa9db64972d49fcfd5 (diff)
downloadtxr-bf643381806466038ed913b084bf20df3fc567e5.tar.gz
txr-bf643381806466038ed913b084bf20df3fc567e5.tar.bz2
txr-bf643381806466038ed913b084bf20df3fc567e5.zip
buf, carray: accessors must eval new value once.
* share/txr/stdlib/ffi.tl (carray-sub, sub-buf): Unfortunately, defset doesn't arrange for the new value to be evaluated once; we must do it.
-rw-r--r--share/txr/stdlib/ffi.tl8
1 files changed, 6 insertions, 2 deletions
diff --git a/share/txr/stdlib/ffi.tl b/share/txr/stdlib/ffi.tl
index 0bf111c0..cf5bd8a1 100644
--- a/share/txr/stdlib/ffi.tl
+++ b/share/txr/stdlib/ffi.tl
@@ -146,10 +146,14 @@
(define-accessor carray-ref carray-refset)
(defset carray-sub (carray : (from 0) (to t)) items
- ^(progn (carray-replace ,carray ,items ,from ,to) ,items))
+ (with-gensyms (it)
+ ^(alet ((,it ,items))
+ (progn (carray-replace ,carray ,it ,from ,to) ,it))))
(defset sub-buf (buf : (from 0) (to t)) items
- ^(progn (replace-buf ,buf ,items ,from ,to) ,items))
+ (with-gensyms (it)
+ ^(alet ((,it ,items))
+ (progn (replace-buf ,buf ,it ,from ,to) ,it))))
(defmacro znew (type . pairs)
(if (oddp (length pairs))