summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-05-14 09:32:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-05-14 09:32:23 -0700
commit30b4cd7fd4aa40616e089b834e34f1928c700ab1 (patch)
tree6aee301a40e21b6950ea1ca5f8bd6dff40f0229d /stdlib
parent5162fde5237ce801f74e8db2bc680f72f00fb0ce (diff)
downloadtxr-30b4cd7fd4aa40616e089b834e34f1928c700ab1.tar.gz
txr-30b4cd7fd4aa40616e089b834e34f1928c700ab1.tar.bz2
txr-30b4cd7fd4aa40616e089b834e34f1928c700ab1.zip
bug: symbol-value place always global.
We have a problem. If v is a dynamic variable, then the form (let (v) (set (symbol-value 'v) 3)) is not behaving correctly; it's updating the top-level value of v not the rebound one. * eval.c (set_symbol_value): New static function. (eval_init): Register sys:set-symbol-value intrinsic. The top-vb variable, though no longer referenced by the symbol-value place, because existing compiled code depends on it. * stdlib/place.tl (symbol-value): Rewrite the place logic to use symbol-value to access the variable, and set-symbol-value to update it, instead of referencing sys:top-vb. (sys:get-vb): This function has to stay, because it provides run-time support for code compiled with the buggy version of the place. * tests/019/symbol-value.tl: New file.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/place.tl8
1 files changed, 4 insertions, 4 deletions
diff --git a/stdlib/place.tl b/stdlib/place.tl
index 13b9bb18..fdd4e544 100644
--- a/stdlib/place.tl
+++ b/stdlib/place.tl
@@ -862,10 +862,10 @@
(defplace (symbol-value sym-expr) body
(getter setter
- (with-gensyms (binding-sym)
- ^(let ((,binding-sym (sys:get-vb ,sym-expr)))
- (macrolet ((,getter () ^(cdr ,',binding-sym))
- (,setter (val) ^(sys:rplacd ,',binding-sym ,val)))
+ (with-gensyms (sym)
+ ^(let ((,sym ,sym-expr))
+ (macrolet ((,getter () ^(symbol-value ,',sym))
+ (,setter (val) ^(sys:set-symbol-value ,',sym ,val)))
,body))))
nil
(deleter