On Friday, 9 February 2018 at 15:06:49 UTC, rumbu wrote:
All understood, but just to get your mind set better, I would
have two quick follow-up questions if you don't mind.
On Friday, 9 February 2018 at 15:06:49 UTC, rumbu wrote:
rough C# translation:
async void spawnedFunc()
{
int i = await receive();
}
OK, but that's because Phobos has no eventloop.
With Vibe.d it looks like this:
```d
auto val = async({
return 32;
}).getResult;
```
Is this really so different or what exactly do you miss from the
language?
C#:
IEnumerable<int> Fibonacci(int limit)
{
int a = 1, b = 1;
while (a < limit)
{
yield return a; //syntactic sugar
var t = a;
a = b;
b = t + b;
}
}
So your point is that std.concurrency.Generator isn't so nice?
Not advertised?
Or do you simply want to have a keyword that wraps a function
into generator like function* in ES6?
---
auto fib = (int limit){
import std.concurrency;
return new Generator!int((){
int a = 1, b = 1;
while (a < limit)
{
a.yield; //syntactic sugar
auto t = a;
a = b;
b = t + b;
}
});
};
---
https://run.dlang.io/is/xQl0Ir