Pair literal for D language

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 28 17:07:06 PDT 2014


On 06/29/2014 12:42 AM, safety0ff wrote:
> On Saturday, 28 June 2014 at 21:51:17 UTC, Ary Borenszweig wrote:
>>
>> I think it's common:
>> http://julia.readthedocs.org/en/latest/manual/types/#tuple-types
>
> Actually, that section is about normal tuples, there is no distinction
> between normal tuples and type tuples in julia.
>  From Julia repl:
> julia> typeof((1,1))
> (Int64,Int64)
> julia> typeof(typeof((1,1)))
> (DataType,DataType)
> julia> typeof((Int64,1))
> (DataType,Int64)
>
> So the equivalent

There's no equivalent. No auto-expansion in Julia. (They do have 
explicit expansion, but an expanded tuple is not an object in its own 
right.)

> to our TypeTuple is a normal tuple containing DataType
> types.

TypeTuple!(int,string) t;

is basically the same as

int __t_field_0;
string __t_field_1;

alias t=TypeTuple!(__t_field_0,__t_field_1);

I.e. D conflates TypeTuple's of types with types of TypeTuples just as 
Julia conflates types of tuples with tuples of types.


More information about the Digitalmars-d mailing list