digitalmars.D - std.concurrency.receive() question
- Ruslan Mullakhmetov (36/36) Aug 11 2013 i try to compile the following slightly modified sample from the
- David Nadlinger (10/11) Aug 11 2013 Hi Ruslan,
i try to compile the following slightly modified sample from the
book and it failed with the following messages
======= source ============
import std.stdio;
import std.concurrency;
void fileWriter()
{
// Write loop
for (bool running = true; running; )
{
receive(
(immutable(ubyte)[] buffer) {},
(OwnerTerminated) { running = false; }
);
}
stderr.writeln("Normally terminated.");
}
void main()
{
}
====== error messages =======
/Users/ruslan/Source/dlang/dub-test/source/listener.d(11): Error:
template std.concurrency.receive does not match any function
template declaration. Candidates are:
/usr/local/Cellar/dmd/2.063.2/libexec/src/phobos/std/concurrency.d(646):
std.concurrency.receive(T...)(T ops)
/Users/ruslan/Source/dlang/dub-test/source/listener.d(11): Error:
template std.concurrency.receive(T...)(T ops) cannot deduce
template function from argument types !()(void
function(immutable(ubyte)[] buffer) pure nothrow safe, void)
========================
what's wrong? if i replace OwnerTerminated with int or simply
remove everything is ok.
if i replace with my own struct Terminate - fail.
any help would be appreciated.
Aug 11 2013
Hi Ruslan,
On Sunday, 11 August 2013 at 13:04:41 UTC, Ruslan Mullakhmetov
wrote:
(OwnerTerminated) { running = false; }
This is a template function literal taking an argument named
"OwnerTerminated", not a function with an unnamed parameter of
type OwnerTerminated. Quite a sublime trap, admittedly.
In the future you might want to post similar questions to the
digitalmars.D.learn group instead.
Hope this helps,
David
Aug 11 2013








"David Nadlinger" <code klickverbot.at>