Variadic grouping
Meta
jared771 at gmail.com
Mon Jul 29 10:57:40 PDT 2013
On Monday, 29 July 2013 at 17:52:41 UTC, Meta wrote:
>> In your notation, it seems like there could be issues. What if
>> T2 is a local variable, then is that an assignment? If there
>> is no possible issues then I wouldn't mind having such a
>> syntax... anything is better than nothing.
>
> I don't think it would be an issue, as it would work the same
> way as local variables in functions that shadow those in an
> outer scope.
>
> ...
Actually, I think I misunderstood your meaning. You're right,
this could be a problem. Currently:
import std.stdio;
void main()
{
int x = 0;
int test(int x, int y)
{
return x + y;
}
//Prints 2
writeln(test(x = 1, 1));
//Prints 1
writeln(x);
}
So in a hypothetical situation where we now have named parameters:
import std.stdio;
void main()
{
int x = 0;
int test(@name("x") x, @name("y") y)
{
return x + y;
}
//Prints 3
writeln(test(x = 1, y = 2));
//What does this print?
writeln(x);
}
More information about the Digitalmars-d
mailing list