DIP 1019--Named Arguments Lite--Community Review Round 1

Yuxuan Shui yshuiv7 at gmail.com
Fri Feb 15 18:36:50 UTC 2019


On Friday, 15 February 2019 at 17:06:18 UTC, Jacob Shtokolov 
wrote:
> On Friday, 15 February 2019 at 12:56:45 UTC, Mike Parker wrote:
>> [...]
>
>
> I think the "Completeness" section contains some arguable 
> points. The proposed solution doesn't take into account the 
> cases where you need to partially skip default arguments.
>
> Say, we have a function:
>
> ```void drawCircle(int x, int y, int radius, Border border = 
> Border.Solid, Bg bg = Bg.Transparent)```
>
> Then we want to call this function with default parameters 
> except the background (bg).
>
> The best way to do that would be:
> ```drawCircle(10, 10, 5, bg: Bg.Red);```
>
> So you see that we omitted the "border" parameter.
>
> However, the proposed solution forces us to do that:
> ```drawCircle(x: 10, y: 10, radius: 5, bg: Bg.Red);```
>
> A lot more unnecessary typing.
>
> Python, for example, allows us to mix both named and unnamed 
> arguments, and thus effectively skip the default ones.

This proposal is written purposefully to minimized its scope. 
Yes, the current proposal doesn't address this use case, but it 
doesn't prevent future DIPs from doing so.


More information about the Digitalmars-d mailing list