summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-30 21:50:32 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-30 21:50:32 -0700
commitd38e9a82b7bdff9f990ff5c5650366890f16cfe8 (patch)
tree2a18ceca967bb988f6da6b1cc9b336dd25b40d22 /share
parentff633e81a1efd932018daa1f887a77d263e4e315 (diff)
downloadtxr-d38e9a82b7bdff9f990ff5c5650366890f16cfe8.tar.gz
txr-d38e9a82b7bdff9f990ff5c5650366890f16cfe8.tar.bz2
txr-d38e9a82b7bdff9f990ff5c5650366890f16cfe8.zip
Define suspend operator.
* lisplib.c (yield_set_entries): Added "suspend" to end of name. * share/txr/stdlib/yield.tl (suspend): New macro. * txr.1: Documented suspend. Replaced subtly incorect shift/reset implementation example with suspend implementation.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/yield.tl8
1 files changed, 8 insertions, 0 deletions
diff --git a/share/txr/stdlib/yield.tl b/share/txr/stdlib/yield.tl
index 236faaa8..3b58ace2 100644
--- a/share/txr/stdlib/yield.tl
+++ b/share/txr/stdlib/yield.tl
@@ -64,3 +64,11 @@
(defmacro yield (form)
^(yield-from nil ,form))
+
+(defmacro suspend (:form form name var . body)
+ (with-gensyms (cap val)
+ ^(tree-bind (,cap . ,val) (sys:capture-cont ',name ',form)
+ (if ,cap
+ (let ((,var ,val))
+ (sys:abscond-from ,name ,*body))
+ ,val))))