<div dir="ltr"><div dir="ltr">On Thu, Nov 5, 2020 at 2:45 PM Q. Schroll 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 Tuesday, 3 November 2020 at 07:05:19 UTC, Manu wrote:<br>
> There's a grammar change that supports:<br>
>    alias staticMap(F, Args...) = F!Args...;<br>
> And also:<br>
>   MyTemplate!(expr...) <-- appearance in template parameter <br>
> lists<br>
><br>
> It's also deliberate and necessary that the grammar is NOT <br>
> modified such<br>
> that `...` could be accepted in argument list definitions, [...]<br>
> I actually really like this incidental restriction; it makes <br>
> declarations clearer.<br>
<br>
I really don't think that such a special case is necessary. Maybe <br>
one way to litigate this is to (using terms just learned from <br>
Andrei) require the pattern to be in parentheses. Since <br>
`identifier...` (where identifier is a tuple) is the same as <br>
`identifier` per se, one could solve the question how long the <br>
`...` expands to the right by requiring parentheses. No one ever <br>
asked how far template arguments are read, i.e. whether T!Arg[0] <br>
means (T!Arg)[0] or T!(Arg[0]) because it is single token or you <br>
need parentheses. Not even T![0,1,2] (an array literal) compiles! <br>
So... maybe it is (pattern)... that is The Right Thing™? That <br>
way, you can have it in function parameter lists:<br>
<br>
     void func((pattern)... args) { .. }<br>
<br>
An example would be<br>
<br>
     void func(Ts...)((Ts[])... args) { .. }<br>
<br>
for a function template taking any kinds of slices. It is <br>
unambiguous because the parentheses aren't legal in current state <br>
of D.<br></blockquote><div><br></div><div>Good point. Except elipsis would be inside the parens.</div><div>That is absolutely possible, and it might even already just happen to work because how the grammar is 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">
Notice that `const(Ts)...` is still the old syntax, i.e. the <br>
`...` are for type-safe variadic parameters. Full example: <br>
<a href="https://run.dlang.io/is/3QvFCA" rel="noreferrer" target="_blank">https://run.dlang.io/is/3QvFCA</a><br>
<br>
Since there are types like int* that can be expressed with a <br>
token sequence that aren't legal as expressions, there is a need <br>
for type patterns and expression patterns; or patterns in general <br>
must accommodate types and expressions together.<br></blockquote><div><br></div><div> </div></div></div>