template parameter list syntax
Carl Sturtivant
sturtivant at gmail.com
Sat Jan 19 16:59:03 UTC 2019
On Saturday, 19 January 2019 at 16:40:42 UTC, Paul Backus wrote:
> On Saturday, 19 January 2019 at 16:36:34 UTC, Carl Sturtivant
> wrote:
>>
>> Why is it that when template arguments are supplied at the
>> point of use, the nice distinguishing syntax of x!(a,b,c) is
>> obligatory, yet when template parameters are supplied at the
>> point of definition the syntax is not distinguished in the
>> same way with a bang !
>
> At the point of use, ! is needed to ensure there's no ambiguity
> between instantiating a template and calling a function.
>
> At the point of definition, there's no ambiguity, so the ! is
> not needed.
Lots of things aren't logically needed. Syntax even: we could all
program in an analog of FORTH using only trivial lexical
structure.
However hopefully some programming languages are designed for
natural intelligibility of some sort via the design of syntax.
In many languages the way parameters for functions are
syntactically specified in a function definition mirrors the way
arguments are supplied when the function is called, so that the
syntax of the definition suggests the syntax of its use.
D doesn't do this with templates. Why?
More information about the Digitalmars-d
mailing list