They basically allow the programmer to make every function into a phobos range.
Instead of iterating through stuff and calculating things you could simply use a generator which will only calculate the first thing and then return that one. Once another one is requested it will start from where it stopped.
import std.concurrency;
import std.stdio;
import std.range;
auto generateIntegers()
{
return new Generator({
int i = 0;
while(true) // wont get stuck here
yield(i++); // because of yield
});
}
void main()
{
generateIntegers().take(50).each!writeln;
// Will print 0-49 to the console
}
https://dlang.org/library/std/concurrency/generator.html
They basically allow the programmer to make every function into a phobos range.
Instead of iterating through stuff and calculating things you could simply use a generator which will only calculate the first thing and then return that one. Once another one is requested it will start from where it stopped.
More information in other languages: http://www.dotnetperls.com/yield