tuples are your friends
Gor Gyolchanyan
gor.f.gyolchanyan at gmail.com
Sat Oct 1 03:17:58 PDT 2011
I wonder why aren't tuples fully supported in D?
string, int, float createTuple()
{
return "hello", 5, 6.7f;
}
unittest
{
string s;
int i;
float f;
s, i, f = createTuple();
}
Wouldn't this be a cleaner way of dealing with static-length
heterogeneous collections of variables?
The comma operator would have a single definite meaning: creating a
tuple out of left-hand variable or tuple and right-hand variable.
The existing use of comma wouldn't change:
* All functions will technically take 1 argument only: a variable or a tuple.
* Comma-separated expressions are technically a single tuple expression.
* UFCS will get expanded to include tuples: ("/", "usr",
"bin").buildNormalizedPath;
It's easy to imagine the same thing but with support for tuples
consisting of any symbols, and nut just variables.
More information about the Digitalmars-d
mailing list