Hi all,

I really like std.concurrency but I now stumbled upon the following.
When receiving messages as const, they also need to be sent as const (otherwise they are not matched). Comparing this to normal function calls I would expect a different behavior.


```d
import std.concurrency;
import std.stdio;

struct Message
{
}

void fun(const(Message) m) {
    writeln("fun(const(Message))");
}
/*
void fun(Message m) {
    writeln("fun(Message)");
}
*/
void receiver()
{
    receive(
        (Tid sender, const(Message) m)
        {
            writeln("received const(Message)");
        },
        (const(Variant) v)
        {
            writeln("Received const(Variant)", v);
        },
        (Variant v)
        {
            writeln("Received variant", v);
        },
    );
    writeln("done");
}
int main(string[] args)
{
    auto blubTid = spawnLinked(&receiver);
    blubTid.send(Message());

    receive(
        (LinkTerminated t)
        {
        }
    );

    fun(Message());
    fun(const(Message)());
    return 0;
}

```

output is something like:
```
Received variantMessage()
done
fun(const(Message))
fun(const(Message))
```

whereas I would expect
```
received const(Message)
done
fun(const(Message))
fun(const(Message))
```

Looking forward for the explanation of that.


Kind regards and happy 2022!
Christian

Reply via email to