DIP 1019--Named Arguments Lite--Final Review
bachmeier
no at spam.net
Fri Aug 23 18:35:26 UTC 2019
On Friday, 23 August 2019 at 17:42:14 UTC, H. S. Teoh wrote:
> But this:
>
> foo(x: 4, y: 8, z: 9,
> screen: scr1, widget: wg2,
> options: opts, menu: menu3);
>
> is no worse than this:
>
> FooParams params;
> params.x = 4;
> params.y = 8;
> params.z = 9;
> params.screen = scr1;
> params.widget = wg2;
> params.options = opts;
> params.menu = menu3;
> foo(params);
What that leads to is this:
foo(x: 4, y: 8, z: 9,
screen: scr1, widget: wg2,
options: opts, menu: menu3);
foo(x: 4, y: 8, z: 9,
screen: scr2, widget: wg2,
options: opts, menu: menu3);
foo(x: 4, y: 8, z: 9,
screen: scr1, widget: wg1,
options: opts, menu: menu3);
You've got a combination of extreme verbosity, hard-to-read code,
and a prolific bug generation machine. The answer to that is to
start currying function arguments or write a customized function
that calls foo while holding fixed certain parameters. It's
extremely clear when you change a single parameter in a struct.
And nobody had to learn yet another piece of syntax in order to
read D code. The best anyone can say is that this is not harmful
in simple cases.
More information about the Digitalmars-d
mailing list