DIP 1031--Deprecate Brace-Style Struct Initializers--Community Review Round 1 Feedback
FeepingCreature
feepingcreature at gmail.com
Thu Feb 13 07:37:24 UTC 2020
On Thursday, 13 February 2020 at 07:29:19 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community
> Review of DIP 1031, "Deprecate Brace-Style Struct Initializers".
Yesss, let's do it. This syntax is a C relic only kept alive by
the lack of viable alternatives. Named arguments functionality
subsumes it completely, especially if it's usable with implicit
struct constructors.
More downsides to {}:
- completely bypasses the constructor
- no way to disable default initialization of fields, making it
silently broken if fields are added
- it's an expression whose validity is dependent on the type it's
being assigned to, and those are always awkward with templated
functions
- hence there's no way to set its type without creating extra
variables
- the syntax awkwardly clashes with object literals in dynamic
languages, as well as hashmaps
More information about the Digitalmars-d
mailing list