DIP 1020--Named Parameters--Community Review Round 2
Yuxuan Shui
yshuiv7 at gmail.com
Thu Sep 12 11:50:13 UTC 2019
On Thursday, 12 September 2019 at 11:46:46 UTC, rikki cattermole
wrote:
> 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?
>
> Yes.
>
> Because you didn't use a named argument.
>
> These would have been valid declarations that would match that
> function call:
>
> 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.
Ah, sorry. I meant to write draw(shape: someShape).
More information about the Digitalmars-d
mailing list