On 08/21/2013 10:53 PM, Dylan Knutson wrote:


I do like the idea of it being called 'static foreach' instead of
'foreach', to keep in step with how the rest of the language handles
other compile time constructs (static assert). Plus, as you said in your
bugreport, visual disambiguation between that and a runtime foreach is
nice feedback for the programmer to pick up instantly.

It's important to keep them separate regardless. static foreach is close to useless if it introduces a new scope for its body.

I.e.:

int main(){
    foreach(_;Seq!int){
        int x;
    }
    return x; // error
}

int main(){
    static foreach(_;Seq!int){
        int x;
    }
    return x; // ok
}

Reply via email to