diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-05-23 06:24:53 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-05-23 06:24:53 -0700 |
commit | d8a9d2e5c9e33515d5a1630ca776454e2f9af242 (patch) | |
tree | c169029d32afc824c2f965c60437e0f2d866c098 | |
parent | c67b29994611dd9f57cad30df20f9ed71a019564 (diff) | |
download | txr-d8a9d2e5c9e33515d5a1630ca776454e2f9af242.tar.gz txr-d8a9d2e5c9e33515d5a1630ca776454e2f9af242.tar.bz2 txr-d8a9d2e5c9e33515d5a1630ca776454e2f9af242.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.tl | 14 |
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))) |