On Mon, 06 Feb 2012 21:26:02 -0500, James Miller <ja...@aatch.net> wrote:
It is also worth noting that the reason delegates are not eligible for
thread spawn is that delegates hold references from outside their
definition. This means that delegates can hold references to data that
outside their thread, thus breaking the rule that all data is
thread-local unless specified otherwise.
The compiler could try to reason about your program and figure out
that your "delegate" doesn't actually access cross-thread data, but
that is very, very hard to prove. D's design is not suited to the
Actor model, at least not without some modification.
He wants to do a delegate of a method from a shared class, there is no
unknown context here. I agree delegate literals should not be eligible.
Then again, those delegates should not be marked shared.
When I tried to run a simple test, the compiler reported:
Error: template std.concurrency.spawn(T...) cannot deduce template
function from argument types !()(void delegate() shared)
So clearly, the compiler knows that the delegate is from a shared object.
This should be doable today...
-Steve