August 22, 2013 [Issue 4085] Steps toward a static foreach | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=4085 --- Comment #10 from bearophile_hugs@eml.cc 2013-08-22 16:50:01 PDT --- Adapted from two comments by Timon Gehr: > 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 > } > > I think the relationship between foreach and static foreach should essentially mirror that of if and static if. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 22, 2013 [Issue 4085] Steps toward a static foreach | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=4085 --- Comment #11 from bearophile_hugs@eml.cc 2013-08-22 16:53:06 PDT --- Another comment by Timon Gehr: > We really need to define a consistent semantics for compile time symbol manipulation though. > > Eg: > > class C{ > int a; > static foreach(x;__traits(allMembers,C)){ > mixin("int "~__traits(identifier,x)~"b;"); > } > } > > What is this supposed to do? "class C{ int a,ab; }"? Non-terminating compilation? Error? > > My best guess is that the above code should be illegal, -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation