DIP 1031--Deprecate Brace-Style Struct Initializers--Community Review Round 1 Discussion
MoonlightSentinel
moonlightsentinel at disroot.org
Sun Feb 16 17:51:27 UTC 2020
On Thursday, 13 February 2020 at 07:29:00 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community
> Review for DIP 1031, "Deprecate Brace-Style Struct
> Initializers":
Effectlively this DIP proposes simplifying the compiler - not so
much the language itself
- primarily because this feature is used seldomly and provides
little value. But there are several problem which undermine this
rationale.
I would argue that this feature is one of the simpler features of
for beginners to learn. You have a struct, enumerate it's field
with appropriate values and get an initialized instance. This has
compelling use cases (which Andre already presented) and were the
alternatives are much more verbose. This is in conflict with one
of D's core strengths, writing expressive and clean code.
This leads to the question why this feature is rarely used. The
current discussion mentions them being type system holes (because
they circumvent constructors) [1] and their restriction to
variable initializers [2]. I think we should address these issues
to increase the usability of the current syntax instead of simply
deprecating it.
Suggestions:
[1] Deprecate (and soon disallow) brace-style initializers for
non-PODs
[2] Allow brace-style initializers wherever a corresponding
struct rvalue is allowed (and can be resolved unambiguously)
More information about the Digitalmars-d
mailing list