Newbie problem

Roger Stokes rs at rogerstokes.free-online.co.uk
Wed Jun 19 08:25:14 PDT 2013


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);
    }
}


More information about the Digitalmars-d-learn mailing list