preparing for named arguments

aliak something at something.com
Mon Aug 26 22:19:38 UTC 2019


So Jonathan brought up a very good point against named arguments 
[0], that D is not consistent at all when it comes to argument 
names. E.g. range functions that have a parameter "r" as opposed 
to parameter "range" (and there're more).

So if named arguments are accepted, from that release onwards 
people will start writing:

choose(condition: true, r1: a, r2: b)
radial(r: a);
take(input: a, n: 3);
takeExactly(range: a, n: 3);
takeOne(source: a);

There're probably a tonne of these with different parameter names 
for a range. It'll be a mess. And then any changes will be 
breaking.

Should we maybe go through and make parameter names consistent 
where they obviously can be before named parameters gets to get 
in (should it get in)? e.g.:

choose(condition: true, range1: a, range2: b)
radial(range: a);
take(range: a, n: 3);
takeExactly(range: a, n: 3);
takeOne(range: a);

[0] 
https://forum.dlang.org/post/mailman.138.1566856133.19826.digitalmars-d@puremagic.com


More information about the Digitalmars-d mailing list