DIP 1030--Named Arguments--Community Review Round 1 Discussion

Steven Schveighoffer schveiguy at gmail.com
Fri Feb 7 15:28:44 UTC 2020


On 2/7/20 5:52 AM, Timon Gehr wrote:
> On 07.02.20 06:00, Steven Schveighoffer wrote:
>> Replying to Timon's post on the feedback thread:
>>
>> On 2/6/20 10:49 PM, Timon Gehr wrote:
>>  > This introduces syntax like:
>>  >
>>  > import std.typecons;
>>  > alias t=AliasSeq!(c:1, a:2, b:3); // valid according to DIP
>>  > void foo(int a,int b,int c){
>>  >      writeln(a," ",b," ",c);
>>  > }
>>  >
>>  > void main(){
>>  >      foo(t);
>>  > }
>>
>> Does it? AliasSeq's template parameter (singular) is named TList, not 
>> a, b, or c.
>>
>> So I would expect this to fail to compile.
> 
> It does add the syntax, and I would argue it is not ideal if this fails 
> to pass semantic analysis.

Yes, it's valid syntax, but shouldn't pass semantic -- you named 
arguments that aren't present (AliasSeq does not have parameters named a 
b or c).

But the DIP isn't 100% clear that named variadics cannot receive 
NamedParameter items. It says extra parameters match the "trailing ... 
of variadic parameter lists and Identifiers are not allowed". Not all 
variadic functions have a trailing ... without a name. I would think 
AliasSeq!(TList: 1, 2, 3) should be valid.

-Steve


More information about the Digitalmars-d mailing list