Fri, 25 Feb 2011 12:18:11 -0800, Jonathan M Davis wrote: > On Friday, February 25, 2011 03:39:31 Morlan wrote: >> While trying to understand the expand mechanism presented in the TDPL >> book I tried to read std.typetuple and std.typecons files. I found a >> true nightmare in those files in the form of an almost infinite chain >> of aliases and macro processing. How can one understand a written text >> if the words are redifined in every other line? And people say that >> goto instruction is bad? Please give me a break. >> >> Anyway, at some point I realized that I cannot understand what is going >> on because there is some language mechanism in action which I do not >> know. I wrote a small program to confirm this. Here it is: >> >> struct S { TypeTuple!(int, double) field; } void main(){ >> S mys; >> mys.field[0] = 4; >> mys.field[1] = 4.4; >> } >> >> It compiles all right. But if you replace the S's definition with {int, >> double field;} >> it does not compile. So tuples are clearly much more than a sequence of >> types and they trigger a completely different semantic action than a >> plain sequence of types. Is there a precise definition of tuples >> somewhere? > > If all you want is a normal tuple, use Tuple from std.typecons. It even > has the convenience function tuple for creating them. TypeTuple is a > different beast entirely, and you probably don't want that unless you > specifically need it. It has to do with processing types and are _not_ > generally what you want. If what you're looking for is tuples, then use > std.typecons.Tuple.
I've used: template Tuple(T...) { alias T Tuple; } Nicely built-in and works in most cases.