Struct Initialization syntax

Seb seb at wilzba.ch
Mon Jul 23 16:26:42 UTC 2018


tl;dr: the currently proposed syntax options are:


---
struct S
{
     int a = 2, b = 4, c = 6;
}
void foo()
{
     bar(S({c: 10})); // Option 1
     bar(S(c: 10));   // Option 2
     bar(S{c: 10});   // Option 3
}
---

So the struct-initialization DIP has been stalled for too long 
and I think it's time we finally get this story done.
I personally prefer option 2, but this might be in conflict to 
named arguments which we hopefully see in the near future too. 
Hence, I'm leaning forward to proposing Option 1 as the 
recommended Option for the DIP (that's also what the PoC DMD PR 
implements). What's your take on this?

DIP: https://github.com/dlang/DIPs/pull/71
Rendered view: 
https://github.com/wilzbach/DIPs/blob/struct-initialization/DIPs/DIP1xxx-sw.md


More information about the Digitalmars-d mailing list