Struct Initialization syntax
Guillaume Lathoud
gsub at glat.info
Wed Jul 25 06:42:32 UTC 2018
On Monday, 23 July 2018 at 18:31:03 UTC, John Colvin wrote:
> On Monday, 23 July 2018 at 16:57:20 UTC, H. S. Teoh wrote:
>> On Mon, Jul 23, 2018 at 04:26:42PM +0000, Seb via
>> Digitalmars-d wrote:
>>> 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
>>> }
>
> ...
>
> Seeing as we already have
>
> S s = { c : 10 };
>
> I'd say it would be fairer to say it resembles anonymous
> function syntax and AA initialisation syntax, but mostly it
> resembles the existing struct initialisation syntax.
Not sure about this, but wouldn't
bar({c: 10});
be consistent with
S s = { c : 10 };
?
More information about the Digitalmars-d
mailing list