template parameter list syntax

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Jan 19 20:52:06 UTC 2019


On Sat, Jan 19, 2019 at 08:06:36PM +0000, Carl Sturtivant via Digitalmars-d wrote:
> On Saturday, 19 January 2019 at 17:59:48 UTC, Paul Backus wrote:
> > On Saturday, 19 January 2019 at 16:59:03 UTC, Carl Sturtivant wrote:
> > > [...]
> > > 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?
[...]

The template function declaration syntax is actually a shorthand for the
so-called eponymous template.  When you write:

	auto myFunc(Args...)(Args args) { }

it's actually a shorthand for:

	template myFunc(Args...) {
		auto myFunc(Args args) { }
	}

For the shorthand to introduce ! would be incongruous because the
template declaration syntax doesn't use !.


T

-- 
Fact is stranger than fiction.


More information about the Digitalmars-d mailing list