The syntax of templates should be similar at the definition as it is at the call site: T sum!(T,R)(R range) if (isInputRange!R...) { ... } Of course, the existing syntax must be kept too.
(In reply to comment #0) > The syntax of templates should be similar at the definition as it is at the > call site: Why?
Of what value is that? The current situation is wonderfully unambiguous. This proposal would make the parser's life harder and would probably make it so that the grammar could no longer be context free (which would be very bad). And from the perspective of the programmer (not just the compiler), it's _useful_ to be able to tell the difference between a template and a template instantiation at a glance.
(In reply to comment #2) > Of what value is that? The current situation is wonderfully unambiguous. > True. > This proposal would make the parser's life harder Not really. Having this as the only template declaration syntax would even make the parser's life easier. (and if both were legal, parsing the kind that has the '!' would be slighly more efficient.) > and would probably make it so that the grammar could no longer be context free This is not the case. The grammar would stay context free. > (which would be very bad). > And from the perspective of the programmer (not just the compiler), it's > _useful_ to be able to tell the difference between a template and a template > instantiation at a glance. The proposal does not put this ability in danger. Anyway, I don't prefer either scheme and in my opinion it is fine to either leave the template declaration grammar as it is, or to change it to always require '!'. The latter is not going to happen though. (I remember that when I wrote my very first function template in D, I used the proposed syntax and was confused that it didn't work.)
> Why? Because one syntax is easier to learn than two. Timon said "when I wrote my very first function template in D, I used the proposed syntax and was confused that it didn't work", and that makes two of us (well, I quickly realized why the compiler complained, but my first instinct is to use !, and it feels really dumb that I can't). Plus, the parser might be able to handle ! more quickly, since it will know to expect "TemplateParameterList" instead of "Parameters".
We have had the syntax without ! in the declaration and things have went very well. This will not be changed.