January 20, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to janderson | janderson wrote:
> Walter Bright wrote:
>> http://www.digitalmars.com/d/template-comparison.html
>>
>> Comments?
>
> What about automatic induction? You probably want to link to a reason why D doesn't have it (since it will probably be questioned again and again). You could also mention how aliasing can go some way to solving this difference.
What is automatic induction?
|
January 20, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> janderson wrote:
>> Walter Bright wrote:
>>> http://www.digitalmars.com/d/template-comparison.html
>>>
>>> Comments?
>>
>> What about automatic induction? You probably want to link to a reason why D doesn't have it (since it will probably be questioned again and again). You could also mention how aliasing can go some way to solving this difference.
>
> What is automatic induction?
Sorry, I mean like:
template <class C>
void Get(C& c) {}
...
int X = 0;
Get(X);
float Y = 0;
Get(Y);
No need to specify the types.
|
January 20, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to janderson | janderson wrote:
> Walter Bright wrote:
>> janderson wrote:
>>> Walter Bright wrote:
>>>> http://www.digitalmars.com/d/template-comparison.html
>>>>
>>>> Comments?
>>>
>>> What about automatic induction? You probably want to link to a reason why D doesn't have it (since it will probably be questioned again and again). You could also mention how aliasing can go some way to solving this difference.
>>
>> What is automatic induction?
>
>
> Sorry, I mean like:
>
> template <class C>
> void Get(C& c) {}
>
> ...
> int X = 0;
> Get(X);
>
> float Y = 0;
> Get(Y);
>
> No need to specify the types.
>
I think its called "Type induction".
-Joel
|
January 20, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros | On Sat, 20 Jan 2007 12:02:34 +0000, Bruno Medeiros wrote:
> BTW, this comparison is very good, unlike the previous one about general language features. It shows how easy it is to use each feature (if available at all), which is what the programmer wants to know, which is what a comparison should show, which in turn most of the time cannot be fully expressed simply with just "Yes|No" remarks. That was a major point of "failure" of the previous comparison table, IMO, it was too fixed in a "has or has not explicit feature X" instead of "how easy it is to do Z".
>
Yes, I agree. Huge improvement! Nice work, Walter! :) -JJR
|
January 20, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to janderson | janderson wrote: > Walter Bright wrote: > >> janderson wrote: >> >>> Walter Bright wrote: >>> >>>> http://www.digitalmars.com/d/template-comparison.html >>>> >>>> Comments? >>> >>> >>> What about automatic induction? You probably want to link to a reason why D doesn't have it (since it will probably be questioned again and again). You could also mention how aliasing can go some way to solving this difference. >> >> >> What is automatic induction? > > > > Sorry, I mean like: > > template <class C> > void Get(C& c) {} > > ... > int X = 0; > Get(X); > > float Y = 0; > Get(Y); > > No need to specify the types. > That is implicit function template instantiation, and D *does* have it. void Get(C)(C c) {} int X = 0; Get(X); float Y = 0; Get(Y); -- Kirk McDonald Pyd: Wrapping Python with D http://pyd.dsource.org |
January 21, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirk McDonald | Kirk McDonald wrote:
> janderson wrote:
>> Walter Bright wrote:
>>
>>> janderson wrote:
>>>
>>>> Walter Bright wrote:
>>>>
>>>>> http://www.digitalmars.com/d/template-comparison.html
>>>>>
>>>>> Comments?
>>>>
>>>>
>>>> What about automatic induction? You probably want to link to a reason why D doesn't have it (since it will probably be questioned again and again). You could also mention how aliasing can go some way to solving this difference.
>>>
>>>
>>> What is automatic induction?
>>
>>
>>
>> Sorry, I mean like:
>>
>> template <class C>
>> void Get(C& c) {}
>>
>> ...
>> int X = 0;
>> Get(X);
>>
>> float Y = 0;
>> Get(Y);
>>
>> No need to specify the types.
>>
>
> That is implicit function template instantiation, and D *does* have it.
>
> void Get(C)(C c) {}
>
> int X = 0;
> Get(X);
>
> float Y = 0;
> Get(Y);
>
Cool. I didn't realize that D now supports that. So why not put these some examples on the webpage instead of just "Yes"?
-Joel
|
Copyright © 1999-2021 by the D Language Foundation