Asynchronous concurrency with reference types

Peter Alexander peter.alexander.au at gmail.com
Sat Feb 5 09:42:53 PST 2011


On 5/02/11 12:11 AM, Sean Kelly wrote:
> Peter Alexander Wrote:
>>
>> Things might be easier if the error messages associated with D's
>> concurrent features weren't especially unhelpful (for example, trying to
>> spawn a thread with reference type parameters just gives you a 'no match
>> for spawn template' error). It's nice that it stops you from doing such
>> things, but it would be nice if it told me why it's not going to let me
>> do them.
>
> Could you provide an example?  When passing reference data, the error you should see is: "Aliases to mutable thread-local data not allowed."  It's a static assert inside send().

Now that I've investigated a bit more, it appears to be unrelated to 
reference types, and instead was an error about using a nested function:

import std.concurrency;
void main()
{
   void foo() {}
   spawn(&foo);
}

---
test.d(5): Error: template std.concurrency.spawn(T...) does not match 
any function template declaration
test.d(5): Error: template std.concurrency.spawn(T...) cannot deduce 
template function from argument types !()(void delegate())
---

Why does it think that the function is a delegate?


More information about the Digitalmars-d-learn mailing list