summaryrefslogtreecommitdiffstats
path: root/stdlib/place.tl
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/place.tl')
-rw-r--r--stdlib/place.tl7
1 files changed, 7 insertions, 0 deletions
diff --git a/stdlib/place.tl b/stdlib/place.tl
index 5d601834..fba9a8d6 100644
--- a/stdlib/place.tl
+++ b/stdlib/place.tl
@@ -374,6 +374,13 @@
^(placelet ((,pl ,place))
(set ,pl (call (opip ,*opip-args) ,pl)))))
+(defmacro ensure (:env env place init-expr)
+ (with-gensyms (existing)
+ (with-update-expander (getter setter) place env
+ ^(iflet ((,existing (,getter)))
+ ,existing
+ (,setter ,init-expr)))))
+
(defmacro defplace (place-destructuring-args body-sym
(getter-sym setter-sym update-body) :
((ssetter-sym clobber-body))