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
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to