Discussion Thread: DIP 1030--Named Arguments--Final Review

Arine arine1283798123 at gmail.com
Fri May 15 23:45:46 UTC 2020


On Wednesday, 13 May 2020 at 00:37:51 UTC, 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.


There's a simple workaround; it can even be deprecated!

struct A {
     int a;
}

// renamed a -> b

struct A {
     int b;
     deprecated alias a = b;
}

I feel like this was mentioned in the last thread too. I don't 
see the point in going around in circles if you aren't going to 
learn anything from it.

> This is similar to:
>
> 1. what happens if the implementer changes the types of the 
> parameters?

It can be deprecated and overloaded at the same time.

> 2. what happens if the implementer changes the order of the 
> parameters?

See above. If they are the same type, then it probably isn't a 
meaningful change and can just be entirely avoided. Really if an 
implementer changes parameters around of the same type then 
that's them purposefully being malicious or they just don't give 
a shit.

> Then user code breaks.
>
> If anything, this feature will motivate implementers to take 
> some care to name the parameters appropriately.

All of these have ways to have the new method and the old method 
existing in the codebase at the same time, with the old method 
being deprecated. It's not equivalent to the current DIPs 
suggested implementation.


More information about the Digitalmars-d mailing list