summaryrefslogtreecommitdiffstats
path: root/stdlib/place.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-10-26 02:33:01 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-10-26 02:33:01 -0700
commit30638a91a2c47acd08cf67735eac31e5adcf4eba (patch)
treebac6ac5c1f3cd4eba8fb2c52c0ef9a01f1649e28 /stdlib/place.tl
parent02a73c7785f5cdd7975cf10f83b430dfcc6778a3 (diff)
downloadtxr-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.tl11
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))))