summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-05-23 06:24:53 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-05-23 06:24:53 -0700
commit782e015d0f235f7e5f66d8becfb7e8361b91825d (patch)
treec169029d32afc824c2f965c60437e0f2d866c098
parent3bcb7ed1b5e6e6a55a8d13f9db96fa7029a99fb4 (diff)
downloadtxr-782e015d0f235f7e5f66d8becfb7e8361b91825d.tar.gz
txr-782e015d0f235f7e5f66d8becfb7e8361b91825d.tar.bz2
txr-782e015d0f235f7e5f66d8becfb7e8361b91825d.zip
placelet: add comment.
* share/txr/stdlib/place.tl (sys:placelet-1): Adding comment explaining why the explicit expansion and temporary proxy place are necessary, even though in most cases it can work fine without them.
-rw-r--r--share/txr/stdlib/place.tl14
1 files changed, 13 insertions, 1 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl
index 26818ce4..985c06fb 100644
--- a/share/txr/stdlib/place.tl
+++ b/share/txr/stdlib/place.tl
@@ -867,7 +867,19 @@
(with-gensyms (tmp-place pl-getter pl-setter)
(unwind-protect
(progn
- (sethash *place-update-expander* tmp-place
+ ;; This temporary proxy place installed into the
+ ;; *place-update-expander* hash, and the forced expansion
+ ;; of the symacrolet form are necessary for correctness.
+ ;; If we don't perform that expand, then the temporary proxy
+ ;; place is not used, and sym ends up being an alias
+ ;; for the getter form (,',pl-getter) of the original place.
+ ;; Then, placelet will only work for places whose getter forms
+ ;; themselves places. This is not required in general. A (foo ...)
+ ;; place can, for instance, use (get-foo ...) and (set-foo ...)
+ ;; getters and setters, where (get-foo ...) is not a place.
+ ;; If sym turns into a symbol macro for a (get-foo ...) form,
+ ;; uses of sym as a place will fail due to get-foo not being a place.
+ (sethash *place-update-expander* tmp-place
(lambda (tmp-getter tmp-setter tmp-place tmp-body)
^(macrolet ((,tmp-getter () ^(,',pl-getter))
(,tmp-setter (val) ^(,',pl-setter ,val)))