digitalmars.D.bugs - [Issue 15692] New: Allow struct member initializer everywhere
- via Digitalmars-d-bugs (33/33) Feb 16 2016 https://issues.dlang.org/show_bug.cgi?id=15692
https://issues.dlang.org/show_bug.cgi?id=15692 Issue ID: 15692 Summary: Allow struct member initializer everywhere Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: doob me.com Currently it's only legal to use struct member initializer when declaring a variable: struct Foo { int a; int b; } void main() { Foo foo = { a: 3, b: 4 }; } It would be a big improvement if something as the following was allowed: Foo{ a: 3, b: 4 } Then it would be possible to use the member initializer syntax in all places a regular struct initializer is supported. For example, together with "auto" and when calling functions: auto foo = Foo{ a: 3, b: 4 }; bar(Foo{ a: 3, b: 4 }); An alternative syntax could be to use parentheses instead: auto foo = Foo(a: 3, b: 4); --
Feb 16 2016