Discussion Thread: DIP 1030--Named Arguments--Final Review
Oraby
hatem.oraby at gmail.com
Wed May 13 02:06:14 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.
>
> 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.
How about providing a migration path by adding the ability to
deprecate named arguments. In such way, libraries can warn users
that a parameter is now deprecated either in favor of
otherparameters or for future removal.
An alternative but similar approach would be to enable functions
to introspect whether a named argument was called as named or
not, in such way the user can provide more verbose deprecation
messages without polluting function signature.
More information about the Digitalmars-d
mailing list