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

jmh530 john.michael.hall at gmail.com
Wed May 13 18:54:58 UTC 2020


On Wednesday, 13 May 2020 at 06:11:46 UTC, Andrej Mitrovic wrote:
> [snip]
>
> 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)`.

So there wouldn't be a warning if they call foo(10, 20)?

That would mean the user couldn't provide an alternate `void 
foo(int x_new_name, int y_new_name) {}` until the deprecation 
period ends. If you make it so that a function with deprecated 
names can only be called with the old names specifically, then 
this would free the implementers up to write a separate function 
with new names. Any call like foo(10, 20) wouldn't change if they 
supply the new function, but a call like foo(x_val: 10, y_val: 
20) would get a deprecation message.

Another way to think of it would be that functions without 
deprecated parameter names have higher priority in the overload 
set than ones with deprecated names.

I think this would resolve my concern with deprecations, if 
Walter goes for it.


More information about the Digitalmars-d mailing list