DIP 1020--Named Parameters--Community Review Round 2

a11e99z black80 at bk.ru
Thu Sep 12 08:44:35 UTC 2019


On Wednesday, 11 September 2019 at 23:01:32 UTC, Walter Bright 
wrote:
> On 9/11/2019 12:18 AM, rikki cattermole wrote:
>> But I need to confirm with you before I do this, is this for 
>> the replacement of in place struct initialization syntax?
>> 
>> If so I want to solve that, but I need to ask you how you 
>> would want it done. Since it touches upon .init, it makes me a 
>> little concerned because of dragons.
>
> I'm planning to replace:
>
>   struct S { int a, b; }
>
>   S s = { 1, 2 };
I don't like this style too.

>   S s = S( a=1, b=2 );
with named args it will be more readable.

but more than this I want next:
> // dont need "new" cuz its not needed for structs
> // and not needed for classes too - they are in GC by default
> auto form = AppWindow {
>     title = "main window",
>     children = [ // child-list
>       TextBox {
>         text = "Hello World!",
>         font = Font { family="Times Roman", height=24 },
>       },
>       Button {
>         text = "Press me!",
>         tilt = Color.Red,
>         click ~= parent.close() // delegate list
>       }
>     ]
>   };

probably it better to do not through constructor but with some 
kind of init-list:
> opAssignInitList( /* what here? tuple? */ ) = default;
that assign automatically to all fields and properties
and just check that no one field/prop assigned more than once



More information about the Digitalmars-d mailing list