Closed aleclarson closed 6 years ago
Just saw that yield
is used for iterables. Maybe for-as
can "just work" with any coroutine, not just iterables?
Also, maybe make it so generators (eg: *fn
/co
functions) are async by default. Since whether or not a generator is async is really an implementation detail, right?
effect
's behavior is somewhere in between throw
and yield
, all three are valid programming patterns
Can a function use all four (effect
, throw
, yield
, await
) or are there restrictions?
Assuming it's a fn () async iter {...}
, then yes it can use all four
What can I do with effect
that I can't do with throw
?
You can resume
it from a catch {}
handler with a value
And should the function be marked as effectful (eg:
*fn () {}
)?Any function that throws would need the asterisk, IMO.
edit: And maybe use
co
instead of*fn
?