DIP 1030--Named Arguments--Community Review Round 1 Discussion

Paul Backus snarwin at gmail.com
Sun Feb 9 18:46:00 UTC 2020


On Sunday, 9 February 2020 at 18:32:45 UTC, Steven Schveighoffer 
wrote:
> But you can name the parameter to the outside and name the 
> parameter differently on the inside:
>
> func foo(milliseconds a: int) -> Void
>
> Now, you call the function with foo(milliseconds: 5), and 
> inside the function, the parameter is named 'a'.
>
> Not sure this could be doable in D. But for a main language 
> that started out with significant naming of parameters 
> (inheriting this from objective-C), it's a good place to look 
> for inspiration here.
>
> -Steve

You can alias the parameter inside the function:

void foo(int milliseconds)
{
     alias ms = milliseconds;
     // Use 'ms' from here on
     // ...
}


More information about the Digitalmars-d mailing list