Hi guys, i noticed a strange compiler error when trying to use the std.concurrency receive.
import std.stdio;
import std.concurrency;
import core.thread;
void workerFunc() {
receive(
(int message) {
writeln("Message ", message);
}
);
}
void main() {
auto worker = spawn(&workerFunc);
worker.send(10);
thread_joinAll();
}
Trying to compile i got error "Error: function expected before (), not module receive of type void"
Note: if i use receiveTimeout instead of receive there is no issue. I'm using dmd version 2.071.0
Comment #1 by schveiguy — 2016-05-25T16:57:15Z
You have a module named receive. Perhaps this module?
Why does receiveTimeout work? because you didn't name your module that :)
You can work around by renaming the import:
import std.concurrency: spawn, con_recv = receive;
or use fully qualified name:
std.concurrency.receive( ...
Comment #2 by schveiguy — 2016-05-25T16:58:38Z
(In reply to Steven Schveighoffer from comment #1)
> You can work around by renaming the import:
>
> import std.concurrency: spawn, con_recv = receive;
Alternatively:
import con = std.concurrency;
...
con.receive( ...
...
con.spawn( ...
Comment #3 by fiorentini — 2016-05-25T17:20:52Z
Ehehee yes, you are right, i made a noob report, sorry guys.