<div dir="ltr"><div dir="ltr">On Fri, Apr 24, 2020 at 2:30 AM Steven Schveighoffer via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 4/23/20 9:53 AM, Manu wrote:<br>
<br>
> <br>
> You can do this by expanding tuples with the appropriate indices:<br>
>    fun(Xs[CrossIndexX], Ys[CrossIndexY])...<br>
> Where CrossIndexX is (0, 0, 1, 1) and CrossIndexY is (0, 1, 0, 1).<br>
<br>
I don't think this works, aren't Xs and Ys tuples also?<br>
<br>
I think what you need is to expand the Xs and Ys into further tuples:<br>
<br>
alias XParams = Xs[CrossIndexX]...;<br>
alias YParams = Ys[CrossIndexY]...;<br>
fun(XParams, YParams)...;<br>
<br>
Which would work I think.<br>
<br>
this means you need 4 pre-expression declarations! Two for the X and Y <br>
expansions, and two for the indexes.<br>
<br>
-Steve<br></blockquote><div><br></div><div>Oh yeah, it was too late at night. Your solution looks right.</div><div><br></div><div><br></div><div>On a slightly unrelated note; there's a really interesting idea up-thread about making nested `...` not be expanded by the outer `...`</div><div>For instance:</div><div><br></div><div>  template T(A, B...) { ... }</div><div>  T!(Tup1, Tup2...)...</div><div><br></div><div>What we're saying here is, Tup2 gets the identity expansion, but that result is NOT expanded with the outer; so the expansion above is:</div><div><br></div><div>  T!(Tup1, Tup2...)...  ->  ( T!(Tup1[0], Tup2...), T!(Tup1[1], Tup2...), ..., 

T!(Tup1[$-1], Tup2...) )<br></div><div><br></div><div>This is opposed to currently where we recurse through nested expansions, effectively:</div><div><br></div><div><div>  T!(Tup1, Tup2)...  ->  ( T!(Tup1[0], Tup2[0]), T!(Tup1[1], Tup2[1]), ..., 

T!(Tup1[$-1], Tup2[$-1]) )<br></div><div></div><div></div></div><div><br></div><div>So, despite Tup2's expansion is the identity expansion, this syntax allows Tup2 to be passed to T!()'s variadic args as the tuple it is, rather than expanded like Tup.</div><div>Using `...` in nested context this way gives articulate control over cases where multiple Tuples in the tree should or shouldn't be expanded by `...`</div><div><br></div><div>I think this is also the natural rule; it follows from the claim that expansion is performed pre-semantic evaluation; nested `...` is only a tuple AFTER evaluation, so it seems natural that it should not be expanded by the outer expansion.</div></div></div>