From 782e015d0f235f7e5f66d8becfb7e8361b91825d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 23 May 2019 06:24:53 -0700 Subject: 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. --- share/txr/stdlib/place.tl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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))) -- cgit v1.2.3