Thread overview
AliasSeq different from just using the symbol name(s)?
Apr 15, 2021
z
Apr 15, 2021
Paul Backus
Apr 15, 2021
z
Apr 15, 2021
z
Apr 15, 2021
Paul Backus
Apr 17, 2021
z
April 15, 2021

I've tried to group together a bundle of alias template parameters with AliasSeq, but while without it works just fine, when the verbose parameters are grouped with multiple AliasSeqs, the lengths of the array parameters passed through AliasSeq are 0(inside the templated function, before the call it's still OK) and a range violation/exception occurs.

This is weird because the templated function does not change the length of its array parameters, and printing the parameter's string name to stdout at runtime shows that they are supposedly the same(in symbol name at least), but somehow it isn't the same?

To see what i mean : https://run.dlang.io/is/VXDRL4 (i could not manage to trigger it here however.)

Big thanks

April 15, 2021

On Thursday, 15 April 2021 at 18:43:29 UTC, z wrote:

>

To see what i mean : https://run.dlang.io/is/VXDRL4 (i could not manage to trigger it here however.)

Without an example that shows the actual problem you encountered, it will be almost impossible for anyone to help you figure out what is causing it.

Since you were not able to trigger it, it seems likely that the problem is related to something other than the AliasSeq which you have left out of the example.

April 15, 2021

On Thursday, 15 April 2021 at 18:58:40 UTC, Paul Backus wrote:

>

Without an example that shows the actual problem you encountered, it will be almost impossible for anyone to help you figure out what is causing it.

Since you were not able to trigger it, it seems likely that the problem is related to something other than the AliasSeq which you have left out of the example.

I understand that it won't be possible to pinpoint the cause without a reduced test case, but :

int[] a,b,c,d,e;
void templatef(args...){/*...*/}
//...
auto seq = AliasSeq!(b,c,d);
templatef!(a,seq,e);
templatef!(a,b,c,d,e); //am i being mistaken for thinking these two template calls should be equivalent in behavior?

And if not, does it mean that the problem i encountered is a possible bug?

April 15, 2021

On Thursday, 15 April 2021 at 19:38:04 UTC, z wrote:

>
int[] a,b,c,d,e;
void templatef(args...){/*...*/}
//...
auto seq = AliasSeq!(b,c,d);
templatef!(a,seq,e);
templatef!(a,b,c,d,e); //am i being mistaken for thinking these two template calls should be equivalent in behavior?

woops, meant void templatef(args...)(){}

April 15, 2021

On Thursday, 15 April 2021 at 19:38:04 UTC, z wrote:

>

I understand that it won't be possible to pinpoint the cause without a reduced test case, but :

int[] a,b,c,d,e;
void templatef(args...){/*...*/}
//...
auto seq = AliasSeq!(b,c,d);
templatef!(a,seq,e);
templatef!(a,b,c,d,e); //am i being mistaken for thinking these two template calls should be equivalent in behavior?

And if not, does it mean that the problem i encountered is a possible bug?

They're not exactly the same. When you write

auto seq = AliasSeq!(a, b, c);

...you are declaring a sequence of three new array variables [1] and initializing them with copies of the original arrays. It's as though you'd written:

auto seq_a = a;
auto seq_b = b;
auto seq_c = c;
alias seq = AliasSeq!(a, b, c);

If you want to refer directly to the original variables, you need to create your sequence with alias instead of auto:

alias seq = AliasSeq!(a, b, c);

[1] https://dlang.org/articles/ctarguments.html#type-seq-instantiation

April 17, 2021

On Thursday, 15 April 2021 at 19:53:57 UTC, Paul Backus wrote:

>

They're not exactly the same. When you write

auto seq = AliasSeq!(a, b, c);

...you are declaring a sequence of three new array variables [1] and initializing them with copies of the original arrays. It's as though you'd written:

auto seq_a = a;
auto seq_b = b;
auto seq_c = c;
alias seq = AliasSeq!(a, b, c);

If you want to refer directly to the original variables, you need to create your sequence with alias instead of auto:

alias seq = AliasSeq!(a, b, c);

[1] https://dlang.org/articles/ctarguments.html#type-seq-instantiation

Ah thank you so much! i changed auto to alias and it worked perfectly.