I'd be grateful for advice. The problem is that I can't get the example
on page 406-7 of the"The D Programming Language " to compile.
I've cut and pasted the text from the website, and corrected the typo (undefined tgt, so use stdout instead). I get this diagnostic:

page406x.d(11): Error: cannot implicitly convert expression (__r24.front()) of type ubyte[] to immutable(ubyte)[]

from this input:

import std.algorithm, std.concurrency, std.stdio;

void main() {
   enum bufferSize = 1024 * 100;
   auto tid = spawn(&fileWriter);
   // Read loop
foreach (immutable(ubyte)[] buffer; stdin.byChunk(bufferSize)) {
      send(tid, buffer);
   }
}

void fileWriter() {
   // Write loop
   for (;;) {
      auto buffer = receiveOnly!(immutable(ubyte)[])();
      stdout.write(buffer);
   }
}

Reply via email to