DIP 1019--Named Arguments Lite--Community Review Round 1

RazvanN razvan.nitu1305 at gmail.com
Mon Feb 18 21:00:35 UTC 2019


On Monday, 18 February 2019 at 19:27:15 UTC, Seb wrote:
> On Monday, 18 February 2019 at 08:32:02 UTC, RazvanN wrote:
>> On Sunday, 17 February 2019 at 21:04:23 UTC, Yuxuan Shui wrote:
>>> [...]
>>
>> How about this: simply adding the ability to name the argument 
>> when calling a function? Example:
>>
>> void rectangle(int width, int height) {}
>>
>> void main()
>> {
>>     rectangle(1, 2);
>>     rectangle(width: 1, height: 2);
>>     rectangle(height: 2, width: 1);
>>     rectangle(width: 1, 2);    // error
>> }
>>
>
>
> 1) What about typos/wrong names?
>
> rectangle(width: 1, hight: 2)

Easy: you print the parameters that do not match: "Unknown 
parameter name". If a parameter name is not in the list of 
parameters, you print it.

>
> 2) How will this deal with parameter renames / deprecation?
>
The easiest solution would be to simply do nothing. Once a 
parameter name is changed, then it has to be updated on caller 
site. Later on we can add smarter stuff.

> If (1) isn't checked, introducing this later would break a lot 
> of code.

Indeed.


More information about the Digitalmars-d mailing list