Discussion Thread: DIP 1030--Named Arguments--Final Review
Paul Backus
snarwin at gmail.com
Tue May 12 17:42:00 UTC 2020
On Tuesday, 12 May 2020 at 12:11:11 UTC, Gregory wrote:
> I also don't like that you can rearrange the arguments into a
> different order. Especially that you can put default arguments
> in the middle. By doing so you are forcing users to use named
> arguments or not use defaults at all. As an example, in C# only
> allows defaults at the end, and named arguments still need to
> be in the correct order. I don't see *any* benefit, nor does
> the DIP describe what benefit this provides. On the other hand
> this makes it more difficult to read, especially (as with the
> example) both functions have the same exact names for their
> parameters. THIS is a feature that should be removed, and if it
> is deemed necessary at a later date then it can be incorporated
> with another DIP. Otherwise trying to fix this later on when it
> is already in use will be almost impossible without breaking
> any code that uses it.
The logic behind this feature is that the rules it uses for
re-ordering are the same ones already used for struct
initializers [1], which are in turn based on the rules used for
designated initializers in C99 [2].
These rules aren't perfect, but consistently using the same rules
for everything is much better than having two separate sets of
rules, and it's too late to go back and change the
struct-initialization syntax now.
[1] https://dlang.org/spec/struct.html#static_struct_init
[2] http://port70.net/~nsz/c/c99/n1256.html#6.7.8p17
More information about the Digitalmars-d
mailing list