I seem to be able to crash writefln

Andrew Wiley debio264 at gmail.com
Wed Mar 9 23:15:13 PST 2011


On Wed, Mar 9, 2011 at 5:19 PM, Joel Christensen <joelcnz at gmail.com> 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
>

My understanding is that the "0..10" isn't actually a range notation,
and you need to use iota(0, 10). I may be wrong, but if I'm right,
hopefully someone can explain why this syntax works?
I remember there being a discussion about this recently; I'll see if I
can find it.


More information about the Digitalmars-d-learn mailing list