diff options
Diffstat (limited to 'gtwiwtg.lisp')
-rw-r--r-- | gtwiwtg.lisp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gtwiwtg.lisp b/gtwiwtg.lisp index 83f7cf5..6f0f6f3 100644 --- a/gtwiwtg.lisp +++ b/gtwiwtg.lisp @@ -749,6 +749,15 @@ This is sort of the opposite of INTERSPERSE!." ;;; CONSUMERS +(defmacro with-generator ((var gen) &body body) + "Use this if you absolutely must manually call NEXT and +HAS-NEXT-P. It will ensure that the generator bound to VAR will be +stopped and cleaned up properly." + `(let ((,var ,gen)) + (assert (typep ,var 'gtwiwtg::generator!)) + (unwind-protect (progn ,@body) + (stop ,var)))) + (defmacro for (var-exp gen &body body) "The basic generator consumer. |