DIP 1019--Named Arguments Lite--Final Review

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Aug 23 18:41:56 UTC 2019


On Fri, Aug 23, 2019 at 01:59:38PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> On 8/23/19 1:42 PM, 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);
> 
> Exactly. It seems that for short lists (2-3 arguments) naming would be
> a net negative (add notational overhead when there's little
> possibility of a confusion to start with). Then, when the list gets
> longer it actually makes matters _worse_ because it disallows skipping
> of defaulted arguments.

Yes, in the case of a proxy argument struct, you can define defaults in
the struct definition and just set the parameters you want, which is a
better solution than this DIP.


> This can't go.

I think the way to move forward is to expand the scope of this DIP to
allow reordering and skipping over default arguments.  I just don't see
the benefit of going through all the trouble of the DIP process and
subsequent implementation work, only to end up with a half-hearted
feature that doesn't even offer these two most desirable things of a
named argument implementation.


T

-- 
Without outlines, life would be pointless.


More information about the Digitalmars-d mailing list