diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-10-26 02:33:01 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-10-26 02:33:01 -0700 |
commit | 30638a91a2c47acd08cf67735eac31e5adcf4eba (patch) | |
tree | bac6ac5c1f3cd4eba8fb2c52c0ef9a01f1649e28 /stdlib/place.tl | |
parent | 02a73c7785f5cdd7975cf10f83b430dfcc6778a3 (diff) | |
download | txr-30638a91a2c47acd08cf67735eac31e5adcf4eba.tar.gz txr-30638a91a2c47acd08cf67735eac31e5adcf4eba.tar.bz2 txr-30638a91a2c47acd08cf67735eac31e5adcf4eba.zip |
places: new accessor read-once.
* lisplib.c (place_set_entries): Trigger autoload on
read-once.
* stdlib/place.t (read-once): New function and place.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'stdlib/place.tl')
-rw-r--r-- | stdlib/place.tl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/stdlib/place.tl b/stdlib/place.tl index 1eb42b56..a08e320a 100644 --- a/stdlib/place.tl +++ b/stdlib/place.tl @@ -862,6 +862,17 @@ ^(macrolet ((,ssetter (val) ^(slotset ,',struct ,',sym ,val))) ,body))) +(defun read-once (value) value) + +(defplace (read-once place) body + (getter setter + (with-gensyms (cache-var pgetter psetter) + (with-update-expander (pgetter psetter) place sys:*pl-env* + ^(slet ((,cache-var (,pgetter))) + (macrolet ((,getter () ',cache-var) + (,setter (val) ^(,',psetter (set ,',cache-var ,val)))) + ,body)))))) + (defmacro define-modify-macro (name lambda-list function) (let ((cleaned-lambda-list (mapcar [iffi consp car] (remql : lambda-list)))) |