On 10-Mar-11 1:04 PM, spir wrote:
On 03/10/2011 12:19 AM, Joel Christensen wrote:
This is on Windows 7. Using a def file to stop the terminal window
coming up.

win.def
EXETYPE NT
SUBSYSTEM WINDOWS

bug.d
import std.stdio;
import std.string;

void main() {
auto f = File( "z.txt", "w" );
scope( exit )
f.close;
string foo = "bar";
foreach( n; 0 .. 10 ) {
writefln( "%s", foo );
f.write( format( "count duck-u-lar: %s\n", n ) );
}
}

output (from in z.txt):
count duck-u-lar: 0

What do you mean, crashing writefln? What do you get on the terminal?
About the file, there seems to be a bug --but unrelated to writefln. The
file is closed, I guess because of scope(exit), before the output stream
is flushed. If this is the right interpretation, then there is a
precedence issue; scope's action should not be performed before the
func's own action is actually completed.

Denis

It quits out the at about the 2nd attempt at printing text (that doesn't go to the terminal because of the def file argument in the compile arguments).

I didn't see any problem with the File stuff, I can use writeln and it does all ten iterations, (not printing any thing of course). I used write instead of writeln, write doesn't flush like writeln, maybe.

I noticed my program that had been running fine before, but suddenly bailed out almost strait away since I used the def file in the compile arguments.

Joel

Reply via email to