Discussion Thread: DIP 1030--Named Arguments--Final Review
Steven Schveighoffer
schveiguy at gmail.com
Wed May 13 14:00:54 UTC 2020
On 5/12/20 8:37 PM, Walter Bright wrote:
> We already have named arguments in D since the very beginning - the
> struct initialization syntax.
>
> Not a single person has complained about breakage when implementers
> changed the names of the struct fields.
As was pointed out in the last review -- if you have structs with public
member fields and you changed those names, the breakage would be more
severe than just a broken initializer call:
auto s = S(1, 2, 3);
writeln(s.foo); // Error, no member foo, did you mean Foo?
It's weird to expect anyone to complain about initializer calls over
actual usage.
> This is similar to:
>
> 1. what happens if the implementer changes the types of the parameters?
>
> 2. what happens if the implementer changes the order of the parameters?
>
> Then user code breaks.
>
> If anything, this feature will motivate implementers to take some care
> to name the parameters appropriately.
I agree, and I don't think this is going to make a huge problem for D.
It would, however, be nice to provide a way to migrate parameter names
like we have for functions (via deprecation attributes).
-Steve
More information about the Digitalmars-d
mailing list