On 05.01.2018 18:41, Adam D. Ruppe wrote:
Y'all know if we write this:

static foreach(foo; [1,2,3]) {
         int blargh = foo;
}

we get:

e2.d(2): Error: variable e2.__anonymous.blargh conflicts with variable e2.__anonymous.blargh at e2.d(2) e2.d(2): Error: variable e2.__anonymous.blargh conflicts with variable e2.__anonymous.blargh at e2.d(2)


because it expands to

int blargh = 1;
int blargh = 2;
int blargh = 3;

all in the same scope. This makes static foreach of fairly little value to me - most times I have considered using it, I end up just using plain old string mixin instead so i can generate names for the declarations.
...
See "limitations" section of DIP 1010 for my thoughts:
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1010.md

(Mixin identifiers are among them. You might also like __local declarations.)

Also see: http://forum.dlang.org/post/[email protected]

Reply via email to