diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-06-17 21:43:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-06-17 21:43:04 -0700 |
commit | 9749c420e5404314f53271d40f1224127b983108 (patch) | |
tree | 0230764153bcbdc066c2453a7cfdbdbbddd9de37 | |
parent | e4a0ff809b8246d3bd5c47d947e51bfcf520d86e (diff) | |
download | txr-9749c420e5404314f53271d40f1224127b983108.tar.gz txr-9749c420e5404314f53271d40f1224127b983108.tar.bz2 txr-9749c420e5404314f53271d40f1224127b983108.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.tl | 8 |
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)) |