Re: The definition of templates in D

2012-03-19 Thread Artur Skawina
On 03/18/12 12:34, Derek wrote: On Sun, 18 Mar 2012 22:00:06 +1100, Derek ddparn...@bigpond.com wrote: The 'adding' is not the point; it could be any functionality. The point I was trying to get across was that it would be useful if the compiler could infer the type parameters of a

The definition of templates in D

2012-03-18 Thread FeepingCreature
A template is a parameterized namespace. That is, it is a namespace (a name through which other objects can be accessed) that may be passed parameters that can modify the nature of the stuff inside. If a template is a compile-time function, then the equivalent of a function call - the

Re: The definition of templates in D

2012-03-18 Thread Derek
On Sun, 18 Mar 2012 17:01:00 +1100, FeepingCreature default_357-l...@yahoo.de wrote: There's a shortcut for this, called IFTI, implicit function template instantiation ... What would be useful is ... template bar(T...){ void bar(T t) { writefln(t); } } int a,b,c; bar!(a, b, c); //

Re: The definition of templates in D

2012-03-18 Thread Andrej Mitrovic
On 3/18/12, Derek ddparn...@bigpond.com wrote: What would be useful is ... bar!(a, b, c); // is equivalent to bar!(int, int, int).bar(a, b, c); You mean like this? template bar(T...) { void bar() { writeln(T); } } void main() { int a = 1, b = 2, c = 3; bar!(a, b, c); }

Re: The definition of templates in D

2012-03-18 Thread Nick Sabalausky
Andrej Mitrovic andrej.mitrov...@gmail.com wrote in message news:mailman.851.1332059038.4860.digitalmar...@puremagic.com... On 3/18/12, Derek ddparn...@bigpond.com wrote: What would be useful is ... bar!(a, b, c); // is equivalent to bar!(int, int, int).bar(a, b, c); You mean like this?

Re: The definition of templates in D

2012-03-18 Thread Derek
On Sun, 18 Mar 2012 19:16:02 +1100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/18/12, Derek ddparn...@bigpond.com wrote: What would be useful is ... bar!(a, b, c); // is equivalent to bar!(int, int, int).bar(a, b, c); You mean like this? template bar(T...) { void bar()

Re: The definition of templates in D

2012-03-18 Thread FeepingCreature
On 03/18/12 11:29, Derek wrote: On Sun, 18 Mar 2012 19:16:02 +1100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/18/12, Derek ddparn...@bigpond.com wrote: What would be useful is ... bar!(a, b, c); // is equivalent to bar!(int, int, int).bar(a, b, c); You mean like this?

Re: The definition of templates in D

2012-03-18 Thread FeepingCreature
On 03/18/12 11:36, FeepingCreature wrote: On 03/18/12 11:29, Derek wrote: On Sun, 18 Mar 2012 19:16:02 +1100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/18/12, Derek ddparn...@bigpond.com wrote: What would be useful is ... bar!(a, b, c); // is equivalent to bar!(int, int,

Re: The definition of templates in D

2012-03-18 Thread FeepingCreature
On 03/18/12 11:39, FeepingCreature wrote: On 03/18/12 11:36, FeepingCreature wrote: On 03/18/12 11:29, Derek wrote: On Sun, 18 Mar 2012 19:16:02 +1100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 3/18/12, Derek ddparn...@bigpond.com wrote: What would be useful is ... bar!(a, b,

Re: The definition of templates in D

2012-03-18 Thread Derek
On Sun, 18 Mar 2012 21:40:10 +1100, FeepingCreature default_357-l...@yahoo.de wrote: On 03/18/12 11:39, FeepingCreature wrote: On 03/18/12 11:36, FeepingCreature wrote: On 03/18/12 11:29, Derek wrote: On Sun, 18 Mar 2012 19:16:02 +1100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote:

Re: The definition of templates in D

2012-03-18 Thread Derek
On Sun, 18 Mar 2012 21:36:46 +1100, FeepingCreature default_357-l...@yahoo.de wrote: why would you do that To make coding easier to write AND read. what do you want to _do_ Infer template arguments from the data types presented in the data values supplied on the instantiation

Re: The definition of templates in D

2012-03-18 Thread Derek
On Sun, 18 Mar 2012 22:00:06 +1100, Derek ddparn...@bigpond.com wrote: The 'adding' is not the point; it could be any functionality. The point I was trying to get across was that it would be useful if the compiler could infer the type parameters of a template instantiation from the types

Re: The definition of templates in D

2012-03-18 Thread Dmitry Olshansky
On 18.03.2012 15:34, Derek wrote: On Sun, 18 Mar 2012 22:00:06 +1100, Derek ddparn...@bigpond.com wrote: The 'adding' is not the point; it could be any functionality. The point I was trying to get across was that it would be useful if the compiler could infer the type parameters of a template

Re: The definition of templates in D

2012-03-18 Thread FeepingCreature
On 03/18/12 12:05, Derek wrote: On Sun, 18 Mar 2012 21:36:46 +1100, FeepingCreature default_357-l...@yahoo.de wrote: why would you do that To make coding easier to write AND read. what do you want to _do_ Infer template arguments from the data types presented in the data values