Re: AliasSeq different from just using the symbol name(s)?

2021-04-17 Thread z via Digitalmars-d-learn

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.


Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread Paul Backus via Digitalmars-d-learn

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 :


```D
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


Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread z via Digitalmars-d-learn

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

```D
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...)(){}`


Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread z via Digitalmars-d-learn

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 :


```D
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?


Re: AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread Paul Backus via Digitalmars-d-learn

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.


AliasSeq different from just using the symbol name(s)?

2021-04-15 Thread z via Digitalmars-d-learn
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