On 03/05/2014 07:58 PM, Andrei Alexandrescu wrote:
On 3/5/14, 10:45 AM, Dicebot wrote:
On Wednesday, 5 March 2014 at 18:39:08 UTC, Andrei Alexandrescu wrote:
Doesn't enable anything. There'd be a ton more juice in a static
foreach; it would enable a lot of great idioms. We should pursue that
instead.

Andrei

Btw, are there any unexpected design difficulties with static foreach?
Or it is just waiting for someone to do the pull request?

The one difficulty is figuring how to allow for all iterations to stay
in the same scope, yet not have duplicate definitions of the iteration
symbol.

static if needs exactly the same thing, currently the following compiles:

static if(is(int A)){}
A b; // meh

It's pretty easy to solve: Just give static if/static foreach it's own scope, but by default forward symbol insertions to the enclosing scope. Symbols introduced by the construct itself are inserted directly into its scope and not forwarded.

Probably worth a DIP. Other than that, we're a go.

Andrei


I will create it this weekend if nobody beats me to it.

Reply via email to