Thread overview
Suggestion: auto templates
Feb 19, 2006
bobef
Feb 19, 2006
Trevor Parscal
Feb 19, 2006
bobef
Feb 19, 2006
Hasan Aljudy
Feb 19, 2006
bobef
Feb 19, 2006
nick
Feb 19, 2006
Sean Kelly
February 19, 2006
It would be nice if there were something like auto templates. I.e. if we have something like:

template mytemplate(_type)
{
	int foo(_type[] ar);
	int boo(_type ar);
}


and type something like

char[] a;
foo(a);
//or even
mytemplate.boo(a[0]);

DMD could autodetect the type and we won't need to specify the type every time manualy.
February 19, 2006
In article <dt9fqs$1v1h$1@digitaldaemon.com>, bobef says...
>
>It would be nice if there were something like auto templates. I.e. if we have something like:
>
>template mytemplate(_type)
>{
>	int foo(_type[] ar);
>	int boo(_type ar);
>}
>
>
>and type something like
>
>char[] a;
>foo(a);
>//or even
>mytemplate.boo(a[0]);
>
>DMD could autodetect the type and we won't need to specify the type every time manualy.

This is a bit ambiguous in actual practice IMHO - but... I also can see how this would be awesome - when this ambiguity would be desired.

Thanks,
Trevor Parscal
February 19, 2006
Trevor Parscal wrote:
> In article <dt9fqs$1v1h$1@digitaldaemon.com>, bobef says...
>> It would be nice if there were something like auto templates. I.e. if we have something like:
>>
>> template mytemplate(_type)
>> {
>> 	int foo(_type[] ar);
>> 	int boo(_type ar);
>> }
>>
>>
>> and type something like
>>
>> char[] a;
>> foo(a);
>> //or even
>> mytemplate.boo(a[0]);
>>
>> DMD could autodetect the type and we won't need to specify the type every time manualy.
> 
> This is a bit ambiguous in actual practice IMHO - but... I also can see how this
> would be awesome - when this ambiguity would be desired.
> 
> Thanks,
> Trevor Parscal


I mean the same way it is possible to write auto a=6;
February 19, 2006
bobef wrote:
> It would be nice if there were something like auto templates. I.e. if we have something like:
> 
> template mytemplate(_type)
> {
>     int foo(_type[] ar);
>     int boo(_type ar);
> }
> 
> 
> and type something like
> 
> char[] a;
> foo(a);
> //or even
> mytemplate.boo(a[0]);
> 
> DMD could autodetect the type and we won't need to specify the type every time manualy.

is this the infamouse implicit template instantiation?
February 19, 2006
Hasan Aljudy wrote:
> bobef wrote:
>> It would be nice if there were something like auto templates. I.e. if we have something like:
>>
>> template mytemplate(_type)
>> {
>>     int foo(_type[] ar);
>>     int boo(_type ar);
>> }
>>
>>
>> and type something like
>>
>> char[] a;
>> foo(a);
>> //or even
>> mytemplate.boo(a[0]);
>>
>> DMD could autodetect the type and we won't need to specify the type every time manualy.
> 
> is this the infamouse implicit template instantiation?

I don't know.
February 19, 2006
It's a variation on it.

bobef wrote:
> Hasan Aljudy wrote:
>> bobef wrote:
>>> It would be nice if there were something like auto templates. I.e. if we have something like:
>>>
>>> template mytemplate(_type)
>>> {
>>>     int foo(_type[] ar);
>>>     int boo(_type ar);
>>> }
>>>
>>>
>>> and type something like
>>>
>>> char[] a;
>>> foo(a);
>>> //or even
>>> mytemplate.boo(a[0]);
>>>
>>> DMD could autodetect the type and we won't need to specify the type every time manualy.
>>
>> is this the infamouse implicit template instantiation?
> 
> I don't know.
February 19, 2006
Hasan Aljudy wrote:
> bobef wrote:
>> It would be nice if there were something like auto templates. I.e. if we have something like:
>>
>> template mytemplate(_type)
>> {
>>     int foo(_type[] ar);
>>     int boo(_type ar);
>> }
>>
>>
>> and type something like
>>
>> char[] a;
>> foo(a);
>> //or even
>> mytemplate.boo(a[0]);
>>
>> DMD could autodetect the type and we won't need to specify the type every time manualy.
> 
> is this the infamouse implicit template instantiation?

Pretty much.


Sean