<div dir="ltr"><div dir="ltr">On Thu, Apr 23, 2020 at 12:55 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/22/20 9:45 AM, WebFreak001 wrote:<br>> if<br>
> f(Items.x...)<br>
> works then what about<br>
> f(Items.MemberTup...) ?<br>
<br>
I would expect an expansion as Manu described, where the natural <br>
expansion of Items becomes Items[0].MemberTup, Items[1].MemberTup, ...<br></blockquote><div><br></div><div>And of course, tuples in tuples auto-flatten according to current D semantics.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
However, there are some ambiguities that I'm not sure have been solved. <br>
What about templates that expand to tuples? Are the results of those <br>
tuples part of the ... expansion?<br>
<br>
What about:<br>
<br>
alias F!(T...) = AliasSeq!(T, T);<br>
<br>
Consider this expansion:<br>
<br>
alias t = AliasSeq!(int, char);<br>
<br>
F!(F!t))...<br></blockquote><div><br></div><div>The expansion is evaluated from the leaf upwards... your question is valid, and this is the case we've discussed quite a lot.</div><div>I'm basically just interested to run it and see what happens naturally!</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Does it mean:<br>
<br>
F!(F!int), F!(F!char)) => int, int, int, int, char, char, char, char<br>
<br>
or does it mean:<br>
<br>
F!(AliasSeq!(int, char, int, char))... => int, char, int, char, int, <br>
char, int, char<br>
<br>
In other words, what if part of the expression *creates* a tuple. Is <br>
that the thing that gets expanded? I would have to say no, right? <br>
Otherwise, the whole thing might be expanded and the ... trivially applied.<br>
<br>
So that means things like (assuming G does something similar but not <br>
identical to F:<br>
<br>
F!(G!int)... would have to be the same as F!(G!int). This might be very <br>
confusing to someone expecting the inner tuple to be done before the <br>
expansion is considered.<br>
<br>
I don't know how to DIP-ify this idea. But it definitely needs to be <br>
talked about.</blockquote><div><br></div><div>I have thought about how to discuss this in the DIP; I describe the semantic, and what happens is what happens.</div><div>This will work, and something will happen... when we implement TemplateInstance, we'll find out exactly what it is :P</div><div>What I will do is show what such a nested tuple does when code works in the DIP to instantiate TemplateInstances.</div><div><br></div><div>It's basically the same thing as what you showed above with: Items[0].MemberTup, Items[1].MemberTup, ...

</div><div>In general, in D currently, nested tuples flatten. Evaluate from the leaf upwards. Your answer will materialise.</div></div></div>