www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Template declaration/instantiation

reply Tom <Tom_member pathlink.com> writes:
Just for curiosity: why template declaration doesn't use '!()' instead of '()'.
Wouldn't using the same symbols in both (the declaration and the instantiation)
be a little more "consistent" to the sight?

Regards,

Tom;
Mar 04 2006
next sibling parent Carlos Santander <csantander619 gmail.com> writes:
Tom escribió:
 Just for curiosity: why template declaration doesn't use '!()' instead of '()'.
 Wouldn't using the same symbols in both (the declaration and the instantiation)
 be a little more "consistent" to the sight?
 
 Regards,
 
 Tom;
The ! syntax was added after the () syntax. Formerly, it was: template Foo(T) { } class A { } instance Foo(int) Foo_int; instance Foo(A) Foo_A; Later on, instance was deprecated and ! came to life. I believe the instance syntax is not valid now. -- Carlos Santander Bernal
Mar 04 2006
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Tom" <Tom_member pathlink.com> wrote in message 
news:duca8l$1mik$1 digitaldaemon.com...
 Just for curiosity: why template declaration doesn't use '!()' instead of 
 '()'.
 Wouldn't using the same symbols in both (the declaration and the 
 instantiation)
 be a little more "consistent" to the sight?
It has to do with it being a context-free grammar. That is, if templates just used plain old parentheses, it would take more work to determine what the symbol was that preceeded them. I like !(), I see it and immediately know I'm dealing with a template. It's like how <> stands out in C++ templates.
Mar 04 2006
parent reply Tom <Tom_member pathlink.com> writes:
In article <ducfbj$1vds$1 digitaldaemon.com>, Jarrett Billingsley says...
"Tom" <Tom_member pathlink.com> wrote in message 
news:duca8l$1mik$1 digitaldaemon.com...
 Just for curiosity: why template declaration doesn't use '!()' instead of 
 '()'.
 Wouldn't using the same symbols in both (the declaration and the 
 instantiation)
 be a little more "consistent" to the sight?
It has to do with it being a context-free grammar. That is, if templates just used plain old parentheses, it would take more work to determine what the symbol was that preceeded them. I like !(), I see it and immediately know I'm dealing with a template. It's like how <> stands out in C++ templates.
I'm not complaining about !(). I'm asking, why not use !() in the template declaration as well. Tom;
Mar 04 2006
parent reply "Walter Bright" <newshound digitalmars.com> writes:
"Tom" <Tom_member pathlink.com> wrote in message 
news:ducikm$232g$1 digitaldaemon.com...
 I'm not complaining about !(). I'm asking, why not use !() in the template
 declaration as well.
Because it's unnecessary from a syntactical point of view.
Mar 04 2006
parent Tom <Tom_member pathlink.com> writes:
In article <ducljs$28f8$1 digitaldaemon.com>, Walter Bright says...
"Tom" <Tom_member pathlink.com> wrote in message 
news:ducikm$232g$1 digitaldaemon.com...
 I'm not complaining about !(). I'm asking, why not use !() in the template
 declaration as well.
Because it's unnecessary from a syntactical point of view.
I know, but it seems more coherent even though it's unnecessary. Tom;
Mar 04 2006