digitalmars.dip.ideas - Varargs concatenation
- monkyyy (31/31) Jun 20 ```d
- Richard (Rikki) Andrew Cattermole (14/18) Jun 20 Note: we can do this today.
- monkyyy (14/20) Jun 20 I think the spec says it *may* but Im pretty sure it *cant* in
```d
alias seq(T...)=T;
alias a=seq!int;
alias b=seq!float;
alias c=a~b;//seq!(int,float)
```
```d
alias a=seq!();
a~=int;
a~=float;//seq!(int,float)
```
Concatenation of vartatic templates will automagically grab their
headers and combine them together
If the templates are different then the first one will be used
```d
alias a=seq!int;
alias b=AliasSeq!float;
static assert(is(a~b==seq!(int,float));
static assert(is(b~a==AliasSeq!(float,int));
```
this will allow pulling out template arguments from a reference
```d
alias badseq(T...)=void;
alias a=badseq!(int,float);
alias b=seq!()~a;//seq!(int,float)
```
it should work with templated structs/functions
```d
struct sumtype(T...){...}
alias a=seq!()~sumtype!(int,float);//seq!(int,float)
```
Jun 20
On 21/06/2025 7:55 AM, monkyyy wrote:alias seq(T...)=T; alias a=seq!int; alias b=seq!float; alias c=a~b;// seq!(int,float)Note: we can do this today. ```d import std.meta; template Foo() { alias A = AliasSeq!int; A = AliasSeq!(A, float); pragma(msg, A); // (int, float) } alias Foos = Foo!(); ``` Unfortunately alias assign doesn't work outside of the template. Hence the template.alias badseq(T...)=void; alias a=badseq!(int,float); alias b=seq!()~a;// seq!(int,float)That can't work, the alias goes bye bye, and it will only see the void.
Jun 20
On Friday, 20 June 2025 at 20:03:29 UTC, Richard (Rikki) Andrew Cattermole wrote:I think the spec says it *may* but Im pretty sure it *cant* in practice, the inherent memoization exists somewhere ```d template badseq(T...){ pragma(msg,T.stringof); alias badseq=void; } unittest{alias a=badseq!(int,float);}//prints unittest{alias a=badseq!(int,float);}//doesnt unittest{alias a=badseq!(int,float);} unittest{alias a=badseq!(int,float);} ```alias badseq(T...)=void; alias a=badseq!(int,float); aliasb=seq!()~a;//seq!(int,float)That can't work, the alias goes bye bye, and it will only see the void.
Jun 20








monkyyy <crazymonkyyy gmail.com>