www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - opApply bug?

reply "Regan Heath" <regan netwin.co.nz> writes:
Calling writefln from within an opApply does strange things..

















































Compile:
dmd test30.d -g -debug -unittest

Output:
READ[1]
READ[Line 2]
READ[Line 3]
READ[Line 4]

Regan
Mar 27 2005
parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
 Compile:
 dmd test30.d -g -debug -unittest

 Output:
 READ[1]
 READ[Line 2]
 READ[Line 3]
 READ[Line 4]
There should be a check for writeable in Stream.writefln and friends that isn't there. What is happening is that the writefln in the opApply is calling the stream's writefln, not std.stdio.writefln. Since the stream is opened in read-only mode writing should be illegal. It will work if you say std.stdio.writefln or if you don't import std.stdio and put stdout.writefln.
Mar 28 2005
parent "Regan Heath" <regan netwin.co.nz> writes:
On Mon, 28 Mar 2005 08:12:47 -0500, Ben Hinkle <ben.hinkle gmail.com>  
wrote:
 Compile:
 dmd test30.d -g -debug -unittest

 Output:
 READ[1]
 READ[Line 2]
 READ[Line 3]
 READ[Line 4]
There should be a check for writeable in Stream.writefln and friends that isn't there. What is happening is that the writefln in the opApply is calling the stream's writefln, not std.stdio.writefln. Since the stream is opened in read-only mode writing should be illegal. It will work if you say std.stdio.writefln or if you don't import std.stdio and put stdout.writefln.
*smacks head* of course! Thanks. So, the write is advancing the read pointer? Is it better to make the read/write pointers independant of each other, or not. IIRC C's FILE api has 1 pointer. What do other implementations use? Regan
Mar 28 2005