On 01/30/2017 11:58 AM, Profile Anaysis wrote:
Also, if one tries to create a global generator an error about PAGESIZE
not being a compile time value is given.

That means you can't initialize it statically, because PAGESIZE is not known statically. But you can have a global (module scope, thread local) Generator. You just have to initialize it dynamically.

----
import std.concurrency: Generator, yield;

/* No: */
/* Generator!int g = new Generator!int({ yield(42); }); */

/* Yes: */
Generator!int g1;
void main()
{
    g1 = new Generator!int({ yield(42); });
}

/* Also yes: */
Generator!int g2;
static this()
{
    g2 = new Generator!int({ yield(42); });
}
----

Reply via email to