DIP 88: Simple form of named parameters

arturg via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 25 09:24:03 PST 2016


On Monday, 25 January 2016 at 16:50:49 UTC, HaraldZealot wrote:
> On Monday, 25 January 2016 at 14:35:09 UTC, arturg wrote:
>> On Monday, 25 January 2016 at 13:40:18 UTC, HaraldZealot wrote:
>> the equal sign cant be used because D behaves like this
>>
>> int width, height;
>>
>> foo(width = 5, height = 10); // 5
>>                              // 10
>> width.writeln;  // 5
>> height.writeln; // 10
>>
>> void foo(int width, int height)
>> {
>>     width.writeln;
>>     height.writeln;
>> }
>>
>
> You didn't pay attention, that in my proposal `foo(width = 5, 
> height = 10);` width and height were declared in place of use, 
> and scope is only this call

this code compiles right now which would make it a breaking 
change if you use the = and change the current behavior

module foo;

int width;
int height;

module app;
import foo;

void bar(int width, int height) {}

void main()
{
     bar(width = 5, height = 10);
}



More information about the Digitalmars-d mailing list