various questions

Jason Spencer spencer8 at sbcglobal.net
Thu Jul 29 13:51:19 PDT 2010


Ok, I've gone over this, adapted it, and mostly understand it.  I just
have one question left:

== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> template Iota(int stop) {
> ...
>         alias TypeTuple!(Iota!(stop-1), stop-1) Iota;
> }
> ...
>     foreach (t; Iota!(str_types.length))

What happens at compile-time with this foreach loop?

I nievely went and replaced "foreach (t; Iota!(str_types.length))"
with "foreach (t; str_types.length)", since the length of that array
is known at compile-time.  That of course bombed, but I don't quite
get why.  Is the compiler actually evaluating the foreach loop at
compile time?  How could it, when the body makes run-time checks?  If
it's not, why doesn't my change work?

Jason


More information about the Digitalmars-d-learn mailing list