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

Seb seb at wilzba.ch
Wed May 13 19:24:46 UTC 2020


On Wednesday, 13 May 2020 at 06:11:46 UTC, Andrej Mitrovic wrote:
> On Monday, 11 May 2020 at 11:37:07 UTC, Mike Parker wrote:
>> This is the discussion thread for the Final Review of DIP 
>> 1030, "Named Arguments":
>>
>> https://github.com/dlang/DIPs/blob/7d114c93edb02d8fc4b05f0716bdb6057905fec2/DIPs/DIP1030.md
>
> I see people mentioning wrapper overloads to enable deprecation 
> of old parameter names. But why not just support this in code?
>
> Something like:
>
> ```D
> void foo (@deprecated("x_val") int x, @deprecated("y_val") int 
> y)
> {
> }
> ```
>
> And then the compiler emits warnings if you use `foo(x_val : 
> 10, y_val : 20)`.

What happens if
a) you change the argument names twice
b) you re-order the argument names
c) you want to change the name and type

tl;dr: I believe it would be more general-purpose if the compiler 
would allow this:

```
void foo(int x, int y) { ... }

@deprecated extern(D, argNames)
void foo(int xVal, int yVal) { ... }
```

And then the compiler prefers non-deprecated overload if it's not 
explicitly requested.

Though that would require including the argument names into the 
function mangling of the deprecated which is requested here with 
the fictional extern (D, argNames).


More information about the Digitalmars-d mailing list