std.concurrency : using delegate in lieu of function
Gabriel Huau
contact at huau-gabriel.fr
Fri Aug 27 09:53:07 PDT 2010
Hello,
I would like to know, why the module std.concurrency use function()
parameter in lieu of delegate ?
Delegate would be usefull for example to pass Function Member to
spawn().
Example :
class Foo
{
void test()
{
for(;;)
{
receive(
(string s) { writeln("string"); }
);
}
}
}
void main()
{
Foo l = new Foo();
void delegate() dg;
dg = &l.test;
auto a = spawn(dg);
a.send("test");
}
I have tested and it worked.
More information about the Digitalmars-d
mailing list