Re: dmd 1.062 and 2.047 release

2010-06-14 Thread torhu

On 15.06.2010 00:45, Sean Kelly wrote:

stdin.byChunk uses a mutable buffer that's overwritten for each chunk so you 
can't ask for an immutable ubyte[] in the foreach line.  Here's the version of 
that sample I used to test (13.7):

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

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

void fileWriter()
{
 // Write loop
 for( ; ; )
 {
 auto buffer = receiveOnly!(immutable(ubyte)[])();
 writeln( "rx: ", buffer );
 }
}


Right, now where's the bugzilla for TDPL? :)


Re: dmd 1.062 and 2.047 release

2010-06-14 Thread Sean Kelly
torhu Wrote:

> I tried the example on page 406-407 of the book (copying stdin to stdout 
> using message passing).  I don't mean to be a killjoy, but it doesn't 
> compile. :(
> 
> I'm using the latest pdf version of the book, and dmd 2.047.
> 
> 
> I get this:
> 
> ---
> d:\prog\dmd\bin\..\src\phobos\std\stdio.d(1902): Error: cannot 
> implicitly conver
> t expression (buffer) of type ubyte[] to immutable(ubyte)[]
> d:\prog\dmd\bin\..\src\phobos\std\stdio.d(7): Error: template instance 
> std.stdio
> .chunks.opApply!(int delegate(ref immutable(ubyte)[] __applyArg0)) error 
> instant
> iating
> ---

stdin.byChunk uses a mutable buffer that's overwritten for each chunk so you 
can't ask for an immutable ubyte[] in the foreach line.  Here's the version of 
that sample I used to test (13.7):

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

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

void fileWriter()
{
// Write loop
for( ; ; )
{
auto buffer = receiveOnly!(immutable(ubyte)[])();
writeln( "rx: ", buffer );
}
}


Re: dmd 1.062 and 2.047 release

2010-06-14 Thread bearophile
> What do you mean?

I have now understood :-)


Re: dmd 1.062 and 2.047 release

2010-06-14 Thread bearophile
Andrei Alexandrescu:
> Thank you guys. Indeed that was my intent.

What do you mean?

Bye,
bearophile


Re: dmd 1.062 and 2.047 release

2010-06-14 Thread Andrei Alexandrescu

bearophile wrote:

I am back.

From the v2.047 changelog:

std.conv: Added file and line information to conversion errors; added brackets '[' 
and ']' around arrays and associative arrays as defaults; added emplace() for 
non-class types.<


This program:

import std.stdio: writeln;
import std.conv: to;
void main() {
int[] a = [1, 2, 3];
writeln(to!string(a));
writeln(a);
}


Prints:
[1 2 3]
1 2 3


But I think if they produce the same default output.

Like:
[1, 2, 3]
[1, 2, 3]

--

I have reopened bug 4109 and in the meantime Shin Fujishiro has closed it 
again. He looks efficient :-)

Bye,
bearophile


Thank you guys. Indeed that was my intent.

Andrei


Re: dmd 1.062 and 2.047 release

2010-06-14 Thread bearophile
I am back.

>From the v2.047 changelog:
>std.conv: Added file and line information to conversion errors; added brackets 
>'[' and ']' around arrays and associative arrays as defaults; added emplace() 
>for non-class types.<

This program:

import std.stdio: writeln;
import std.conv: to;
void main() {
int[] a = [1, 2, 3];
writeln(to!string(a));
writeln(a);
}


Prints:
[1 2 3]
1 2 3


But I think if they produce the same default output.

Like:
[1, 2, 3]
[1, 2, 3]

--

I have reopened bug 4109 and in the meantime Shin Fujishiro has closed it 
again. He looks efficient :-)

Bye,
bearophile