On 3/9/12 10:16 AM, Timon Gehr wrote:
There are two parts, syntax and semantics.Semantics: D is already able to express those: template Tuple(T...){alias T Tuple;} // not the same as std.typecons.Tuple! // function with multiple return values: Tuple!(int,double) foo(int a, double b){ Tuple!(int, double) result; // ok, _no imposed memory layout_ result[0] = a; // ok result[1] = a+b; // ok return result; } Multiple return values are currently *disallowed explicitly*: DMD sez: "Error: functions cannot return a tuple" Just specify the ABI, implement the code gen, and we're done. Moot point: built-in tuples auto-flatten inside comma-separated lists. std.typecons.Tuple is a hack to circumvent the arbitrary "cannot return tuple from function" restriction as well as the auto-flattening.
No, it was more like an implementation of a generic tuple.
The problem is that it is implemented as a struct with a built-in tuple member. The fact that it is a struct imposes a memory layout. This is just a side-effect of attempting to address the other two issues. It is not something that is desirable.
Why? I don't understand what you're trying to solve, that Tuple is not good at. Andrei
