Hello,
I have a proposal: make corotines more explicit in use, than it is proposed right now. The thing is: a function is treated as coroutine, when a 'co_yield' or 'co_return' keyword is used inside callable object's body. Whether a function is a coroutine or not,
is determined by it's body, not by it's definition. In my opinion this is a language flaw. Therefore I suggest creating a new keyword: 'coroutine', which is going to be a type-specifier to a function or lambda expression and then, changing the upcoming keywords
related to coroutines ('co_await', 'co_yield', 'co_return' to 'await', 'yield' and 'return' respectively). As always, it is better to see the syntax in action, so there's the example:
coroutine auto iota(int n = 0)
{
while(true)
yield n++;
}
would be equivalent to proposed:
auto iota(int n = 0)
{
while(true)
co_yield n++;
}
Or with lambda expression:
auto getFive = []() coroutine // in the same place as 'constexpr' keyword
{
return 5;
};
which of course would be equivalent to:
auto getFive = []()
{
co_return 5;
}
Why 'coroutine' keyword? Firstly, coroutine should be specified by it's declaration,