Tuples a first class feature, manu's new unary operator and named arguments

Walter Bright newshound2 at digitalmars.com
Sat May 9 23:26:30 UTC 2020


On 5/9/2020 12:08 AM, Manu wrote:
> For instance, it would be nice for a function to return a tuple:
>    AliasSeq!(int, float) mrv() { return AliasSeq!(1, 1.0f); }
> 
> But that doesn't really make sense from the perspective of the template arg list 
> hack we use, relative to a proper language tuple.
> Instead we use a struct named `Tuple`, which isn't a tuple, it's a struct, and 
> it infers a lot about ABI, move/copy semantics, etc.

D already merges the notion of a struct and an array, e.g.:

    struct S { int a,b,c; }
    int[3] a;

are passed/returned in an identical manner. (Went to considerable effort to make 
this happen.) I wished to have it include:

    AliasSeq!(1, 2, 3)

behaving the same way. But, alas, the function ABI makes that impossible. struct 
S is passed to a function *differently* from 1,2,3, and a tuple parameter is the 
same as 1,2,3, not like a struct literal {1,2,3}.


More information about the Digitalmars-d mailing list