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
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( ...
(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( ...
Ehehee yes, you are right, i made a noob report, sorry guys.
No worries! Welcome to D :)