The built-in tuple is also quite useful when defining templates.
In essence, we have two kinds of tuples: the built-in language
tuple is the "unpacked" tuple while Phobos hosts the "packed"
one. They each have their own use case and they can coexist
peacefully. But the language itself needs to standardize on one
or the other.
+1, and it should standardize on "packed" (non-expanded) tuples
because "unpacked" ones have very unusual behavior, and because
it's impractical to eliminate "packed" tuples but practical to
eliminate "unpacked" ones. "unpacked" tuples should only exist as
an intermediate result (the result of .expand).
If the language made T… a packed tuple instead, then we could
use the packed tuple everywhere and unpack it where necessary,
and something like this could be used to make a packed tuple:
T getThings(T...)(T.expand t)
{
return T(t);
}
T t1;
T t2 = getThings!(T)(t1.expand);
"T.expand" naturally has the connotation "unpacked" to me,
whereas what you really want to do is indicate that "t" is
packed, right? Clearly, the syntax for a varargs template like
this would have to change to indicate that T is non-expanded;
unfortunately, I don't have a really compelling syntax to suggest.
P.S. If non-expanded tuples were the default, they should
probably have a quicker syntax than "t.expand" to expand them. I
suggest overloading unary * as in "*t"; this is known as the
"explode" operator in boo.