digitalmars.D - Template declaration/instantiation
- Tom <Tom_member pathlink.com> Mar 04 2006
- Carlos Santander <csantander619 gmail.com> Mar 04 2006
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Mar 04 2006
- Tom <Tom_member pathlink.com> Mar 04 2006
- "Walter Bright" <newshound digitalmars.com> Mar 04 2006
- Tom <Tom_member pathlink.com> Mar 04 2006
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
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
"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
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
"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
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









Carlos Santander <csantander619 gmail.com> 