Wait, how do you run two coroutines in parallel? Like, how do I write zip() or something like it?
a() -> Int() | Void
b() -> Int() | Void
for(a()) {
| na -> for(b()) {
| nb ->
print(na + nb)
// now what? From here, I want to continue to a(), not b()
I don't believe there is much use for coroutines without support for their interleaved execution.
Generators are a thing in multiple languages that are essentially this (javascript, C# to name a couple). It’s nice for creating lazily iterators ergonomically
Yes, I know it's an omission by the author but since the interleaving is IMHO the sine qua non for coroutines it's a glaring omission. Without it, the whole proposal looks like a large heap of machinery and complicated syntax that still only supports sequential execution which traditional languages support well enough already, thanks.
You have to liberate yourself from tick-tock synchrony.
There are 'a' and 'b' processes, they generate messages. You cannot predict how those will arrive. If you want them strictly alternating, you can tag each of the messages with the source, and block until you get the next other one you expect. Or you can just receive them all and make sense of them on their own terms.
> You have to liberate yourself from tick-tock synchrony.
Thank you for telling me which kinds of program I am not allowed to write any more in the bright new future of the programming.
As for the rest of your comment, I am aware of CSP and its derivatives, thanks. The question was about the language proposed in TFA that seems to be lacking the choice/select primitive.