DIP 1020--Named Parameters--Community Review Round 2

rikki cattermole rikki at cattermole.co.nz
Thu Sep 12 11:46:46 UTC 2019

On 12/09/2019 11:29 PM, Yuxuan Shui wrote:
> Dumb question: @named parameters are ignored in overload resolution, so 
> in this example:
> void draw(@named Circle shape);
> void draw(@named Rectangle shape);
> Is a call to draw:
> draw(someShape);
> always going to be a compilation error?


Because you didn't use a named argument.

These would have been valid declarations that would match that function 

void draw(Circle shape);
void draw(Rectangle shape);

In this example you didn't need named parameters.
Since the variable name of the calling body should be descriptive enough 
to tell you that it is a circle/rectangle.

More information about the Digitalmars-d mailing list