www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19115] New: Object and Collection Initializers

https://issues.dlang.org/show_bug.cgi?id=19115

          Issue ID: 19115
           Summary: Object and Collection Initializers
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: black80 bk.ru

Add initialization lists to D. 
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers
it can be useful in many case: JSON, GUI..
  auto lbl = new Label { Text: "hello", Color: Colors.red };

and even more
I think that it should be extended like WITH-keyword in some languages 
(lbl is variable from code above, it's created already, we just want change
some props):
  lbl = { Text: "hello again", Color: Colors.green }; // no temporary vars
here.
// Text & Color belong to "lbl" variable. same as
  lbl.Text = "hello again";
  lbl.Color = Colors.green;
// colon":" that means assign"=" looks a little bit weird imo, but like in
JSON/JS
or same as "with" keyword in some unknown language
  with lbl {
    Text = "hello again",
    Color = Colors.green,
  }

--
Jul 24 2018