[DIP] In-place struct initialization
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Thu Aug 4 23:27:04 PDT 2016
On Friday, 5 August 2016 at 06:12:24 UTC, ZombineDev wrote:
> I was actually looking for design issues. Assuming this bug
> gets fixed, and
> S s = { a: var1, b: var2 }, becomes equivalent to:
> S s = void;
> s.a = var1; /* calls s.a postblit if necessary */
> s.b = var2; /* calls s.b postblit if necessary */
tbh, i'm not a big fan of "{}" initialization syntax. it looks so
out of place for me that i didn't even used it once (the bug i
found was from alien code ;-).
besides, all this thread looks like a thing that is curing
symptoms for me. by introducing general named arguments support,
structure ctors with arbitrary fields comes naturally then (not
without some code, but it will *look* naturally).
i.e. names args will allow to call any function like `foo(b:42,
a:"hi")`, and then autocreated struct ctors should not be an
exception.
sorry for not being constructive, but you asked, and i again
can't resist the temptation.
More information about the Digitalmars-d
mailing list