Fully dynamic d by opDotExp overloading

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Apr 18 08:12:49 PDT 2009


downs wrote:
> Static loops are simple, at least in functions.
> 
> import std.stdio;
> 
> template Tuple(T...) { alias T Tuple; }
> template Repeat(T, int I) { static if (!I) alias Tuple!() Repeat; else alias Tuple!(T, Repeat!(T, I-1)) Repeat; }
> 
> void main() {
>   foreach (i, bogus; Repeat!(void, 15))
>     writefln(i);
> }

I know, but at about the fiftienth one you get sick of it. And 
generating code in a static loop is much harder.

Andrei



More information about the Digitalmars-d mailing list