On 3/10/11 4:40 AM, Andrew Wiley wrote:
On Thu, Mar 10, 2011 at 1:31 AM, Jonathan M Davis<jmdavisp...@gmx.com>  wrote:
On Wednesday 09 March 2011 23:15:13 Andrew Wiley wrote:
On Wed, Mar 9, 2011 at 5:19 PM, Joel Christensen<joel...@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.

0..10 works with foreach. It's specific to foreach. iota also works, because it
produces a range rather being built in to the language. As such, iota works in
places _other_ than foreach. But 0..10 works just fine in foreach. It definitely
pre-dates iota.

- Jonathan M Davis


Ah, then I guess I just need to learn me some D. Sorry for the noise.

No, D needs to change, not you. Ah, consistency...

Reply via email to