Tuple/TypeTuple etc.
John Colvin
john.loughran.colvin at gmail.com
Sat Aug 17 04:43:07 PDT 2013
On Saturday, 17 August 2013 at 01:01:10 UTC, Dicebot wrote:
> Currently it is not the case. typeof(tuple(1,2)) is
> Tuple!(int,int), not TypeTuple!(int, int). But
> typeof(TypeTuple(1,2)) is TypeTyple!(int, int) :)
Whu?
There is no such type as TypeTuple!(int, int), it is completely
aliased away to a builtin tuple.
Also, printing out types is actually rather misleading, as it
chooses when to use or not use tuple() in annoying ways e.g.
TypeTuple!(int, string) is (int, string) but TypeTuple!(int, 3)
is tuple(int, 3) Either they are both tuples, or neither is.
To the best of my knowledge, there is only this:
1) collections of items, called tuples. They can contain pretty
much anything you want, as long it's available at compile-time.
They are ***not types***. If and only if a tuple contains only
types, the tuple itself is a type. This is often referred to as a
type-tuple. In current D, tuples of all varieties are created by
variadic template parameters.*
2) instantiations of type-tuples. These are a collection of
runtime values, individually accessible by indexing or foreach
iteration. std.typecons.Tuple is a wrapper around one of these
providing some extra functionality.
*std.typetuple.TypeTuple only exists to provide convenient syntax
for this.
More information about the Digitalmars-d
mailing list