November 09, 2011 [Issue 6917] New: with() at global scope too | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6917 Summary: with() at global scope too Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-11-08 19:24:43 PST --- A correct D2 program that defines a global immutable array of enum members: enum MyEnum { first, second } immutable MyEnum[] array = [MyEnum.first,MyEnum.second,MyEnum.second, MyEnum.first,MyEnum.second,MyEnum.second]; void main() {} To reduce the noise I'd like to use with() at global scope too (there is no need to call is "static with"): enum MyEnum { first, second } with (MyEnum) { immutable MyEnum[] array = [first,second,second,first,second,second]; } void main() {} with is useful for global structs too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 09, 2011 [Issue 6917] with() at global scope too | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6917 --- Comment #1 from bearophile_hugs@eml.cc 2011-11-09 05:12:18 PST --- This is a workaround, but I try to avoid static this where possible to avoid circular reference import troubles: enum MyEnum { first, second } immutable MyEnum[] array; static this() { with (MyEnum) array = [first,second,second,first,second,second]; } void main() {} -- 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