A Discussion of Tuple Syntax

Meta jared771 at gmail.com
Mon Aug 19 16:55:20 PDT 2013


On Monday, 19 August 2013 at 23:48:36 UTC, Meta wrote:
> ...

An addendum:

void main()
{
	//Prints 1
	writeln(func(TypeTuple!(1, 2)));
}

int func(int i, int j)
{
	return i;
}

This is bad and should never be allowed with some hypothetical 
tuple literal syntax. The desired behaviour is:

void main()
{
     //Error: func is not callable using argument types (#(int, 
int))
     writeln(func(#(1, 2));
}

*Unless* you use .expand/[] (pick your poison):

void main()
{
     writeln(func(#(1, 2).expand)); //Or #(1, 2)[]
}


More information about the Digitalmars-d mailing list