www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15692] New: Allow struct member initializer everywhere


          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

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