DIP 1019--Named Arguments Lite--Community Review Round 2
Jonathan Marler
johnnymarler at gmail.com
Thu Jun 6 19:48:12 UTC 2019
On Thursday, 6 June 2019 at 19:30:36 UTC, Jonathan Marler wrote:
> On Thursday, 6 June 2019 at 19:17:38 UTC, Jonathan Marler wrote:
>> [...]
>
> By the way, I like what the DIP is trying to do, where it is
> trying to enable named parameters using the "least common
> denominator". It attempts to do as little as possible to
> increase the likelihood of acceptance and leaves room for
> future improvements to address things like re-ordering/omission
> of default parameters, features which may or may not be
> justified but shouldn't keep us from having named parameters.
>
> However, the way in which it was designed where it suddenly
> exposes the parameter names of all functions to all callers is
> not what we want. I think the "least common denominator" is to
> provide some way for the function definition to distinguish
> between named and un-named parameters. Something like this:
>
> void foo(int a, int b, int c, alias int d, int e, int f)
> ^ ^
> unnamed parameters (left of alias) named parameters (right
> of alias)
>
> foo(1, 2, 3, d:4, e:5, f:6)
One more thought, probably should be `public` instead of `alias`
to enabled named parameters:
void drawRect(public int x, int y, int width, int height);
drawRect(x: 0, y: 0, width: 1, height: 1);
void calculateProduct(int[] values, public int multipler, public
bool goFast, Allocator* allocator);
calculateProduct(value, multiplier: 7, goFast: false, allocator:
null);
More information about the Digitalmars-d
mailing list