Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 19, 2006 Suggestion: auto templates | ||||
---|---|---|---|---|
| ||||
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 Re: Suggestion: auto templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | 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 Re: Suggestion: auto templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trevor Parscal | 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 Re: Suggestion: auto templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | 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 Re: Suggestion: auto templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hasan Aljudy | 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 Re: Suggestion: auto templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to bobef | 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 Re: Suggestion: auto templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hasan Aljudy | 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
|
Copyright © 1999-2021 by the D Language Foundation