On Sat, 05 Feb 2011 20:42:53 +0300, Peter Alexander <peter.alexander...@gmail.com> wrote:

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?

Because even though foo doesn't use any of the local variables (nor does main declare any), it still has frame pointer as if it was using some:

void main()
{
    int x = 42;
    void foo() { printf("%d", x); }
    spawn(&foo);
}

Reply via email to