From a89c377c9225e593037f07ed4a4d13b6474b8eea Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Thu, 22 Jul 2021 17:59:01 -0500 Subject: [PATCH] Add the `fiber-fn` macro which slightly generalizes `coro`. --- src/boot/boot.janet | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index d7e1bbe2..98e59948 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -588,10 +588,15 @@ ~(fiber/new (fn [] (loop ,head (yield (do ,;body)))) :yi)) (defmacro coro - "A wrapper for making fibers. Same as (fiber/new (fn [] ;body) :yi)." + "A wrapper for making fibers that may yield multiple values (coroutine). Same as (fiber/new (fn [] ;body) :yi)." [& body] (tuple fiber/new (tuple 'fn '[] ;body) :yi)) +(defmacro fiber-fn + "A wrapper for making fibers. Same as (fiber/new (fn [] ;body) flags)." + [flags & body] + (tuple fiber/new (tuple 'fn '[] ;body) flags)) + (defn sum "Returns the sum of xs. If xs is empty, returns 0." [xs]