From 9749c420e5404314f53271d40f1224127b983108 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 17 Jun 2019 21:43:04 -0700 Subject: 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. --- share/txr/stdlib/ffi.tl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'share') 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)) -- cgit v1.2.3