diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-10-26 07:46:17 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-10-26 07:46:17 -0700 |
commit | bf96924d0781b62ea447a01e9bc7a395f0bf609d (patch) | |
tree | d960eca68c0793c1443f62d4cd7b49d6a9cee164 | |
parent | 64e0f2c2f3fb9c543f247fb65172fc4690018bbc (diff) | |
download | txr-bf96924d0781b62ea447a01e9bc7a395f0bf609d.tar.gz txr-bf96924d0781b62ea447a01e9bc7a395f0bf609d.tar.bz2 txr-bf96924d0781b62ea447a01e9bc7a395f0bf609d.zip |
ifa: take advantage of read-once.
* stdlib/ifa.tl (ifa): When the form bound to the it
anaphoric variable is a place, such that we use placelet,
wrap the place in (read-once ...) so that multiple
evaluations of it don't cause multiple accesses of the
place.
* txr.1: Documented.
-rw-r--r-- | stdlib/ifa.tl | 2 | ||||
-rw-r--r-- | txr.1 | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/stdlib/ifa.tl b/stdlib/ifa.tl index eaab6f3a..317ef9e7 100644 --- a/stdlib/ifa.tl +++ b/stdlib/ifa.tl @@ -54,7 +54,7 @@ (let* ((btemps (mapcar (ret (gensym)) before-it)) (atemps (mapcar (ret (gensym)) after-it))) ^(let (,*(zip btemps before-it)) - (placelet ((it ,it-form)) + (placelet ((it (read-once ,it-form))) (let (,*(zip atemps after-it)) (if (,sym ,*(if (eq 'dwim sym) ^(,(second test))) ,*btemps it ,*atemps) @@ -16915,7 +16915,13 @@ alias is used multiple times in the .meta then or .meta else -expressions. Otherwise, if the form is not a syntactic place +expressions. Furthermore, the place form is implicitly surrounded with +.code read-once +so that the place's value is accessed only once, and multiple references to +.code it +refer to a copy of the value cached in a hidden variable, rather than +generating multiple accesses to the place. +Otherwise, if the form is not a syntactic place .code it is bound as an ordinary lexical variable to the form's value. |