mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 19:19:53 +00:00
Add the fiber-fn
macro which slightly generalizes coro
.
This commit is contained in:
parent
54d73f6722
commit
a89c377c92
@ -588,10 +588,15 @@
|
|||||||
~(fiber/new (fn [] (loop ,head (yield (do ,;body)))) :yi))
|
~(fiber/new (fn [] (loop ,head (yield (do ,;body)))) :yi))
|
||||||
|
|
||||||
(defmacro coro
|
(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]
|
[& body]
|
||||||
(tuple fiber/new (tuple 'fn '[] ;body) :yi))
|
(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
|
(defn sum
|
||||||
"Returns the sum of xs. If xs is empty, returns 0."
|
"Returns the sum of xs. If xs is empty, returns 0."
|
||||||
[xs]
|
[xs]
|
||||||
|
Loading…
Reference in New Issue
Block a user