January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright escribió: > http://www.digitalmars.com/d/template-comparison.html > > Comments? What about the general comparison (http://www.digitalmars.com/d/comparison.html), it's me or C, C++, C# and Java are gone? -- Leandro Lucarella Integratech S.A. 4571-5252 |
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | "Walter Bright" <newshound@digitalmars.com> wrote in message news:eoq501$1380$1@digitaldaemon.com... > http://www.digitalmars.com/d/template-comparison.html > > Comments? In the "Pointer parameters" row, you might also want to add "delegates" to the D column, and make some mention of that ability in the "Pointer to member parameters" row (i.e. "No, D doesn't have pointers to parameters, it has delegates instead"). This table also makes some things clear that would be nice to have in D. The ones that jump out at me are templated constructors and overloading templated functions with other functions. |
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | "Leandro Lucarella" <llucarella@integratech.com.ar> wrote in message news:eoqhgk$1nuq$2@digitaldaemon.com... > Walter Bright escribió: >> http://www.digitalmars.com/d/template-comparison.html >> >> Comments? > > What about the general comparison (http://www.digitalmars.com/d/comparison.html), it's me or C, C++, C# and Java are gone? Walter took those out because the chart was deemed.. inflammatory? Negative in some way. |
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Fri, 19 Jan 2007 13:02:47 +0300, Walter Bright <newshound@digitalmars.com> wrote: > http://www.digitalmars.com/d/template-comparison.html > > Comments? In the sample: template<class T> class Foo { typedef int A; }; template<class T> class Bar : Foo<T> { A x; // error }; it's more correctly to use protected or public keyword in Foo, I think: template<class T> class Foo { protected: typedef int A; }; because in original code A is a private member of Foo and cannot be accessed from derived classes. And a question. It's necessary to use 'typename T<U>::' in C++ to access to typedef in some template class. Even when classes are not related as base/derived: template< class T > struct Iterator { typedef T value_type; typedef T * pointer_type; }; template< class I > struct IteratorAdapter { typename Iterator< I >::pointer_type ptr; }; int main() { IteratorAdapter< int > a; } I think the same situation is in your sample, because Foo<T> is a template class and it is necessary to use 'typename Foo<T>::' as a prefix for A in Base. So, do you think your sample 'Dependent Base Class Lookup' is correct in this context? May be better to speak about access to typedefs/alias in D's templates without 'typename' keyword? -- Regards, Yauheni Akhotnikau |
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> http://www.digitalmars.com/d/template-comparison.html
>
> Comments?
Informative chart, links to spec and other articles about templates might be useful.
Not sure if these belong to the chart, but I find the following features quite valuable with or in conjunction with templates:
- Static assert, a no-brainer.
- Compile time messages, with static assert for example. I guess this by virtue of the .mangleof property with compile time string parsing? (I'm thinking of Don Clugston's meta.nameof library). Anyway the ability to easily give meaningful and readable error messages without resorting to compiler output parsing like STLlift can be a big time-saver.
- 'is' expressions
- templated mixins
|
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Don Clugston wrote:
> Walter Bright wrote:
>> http://www.digitalmars.com/d/template-comparison.html
>>
>> Comments?
>
> You left out specialisation of template value parameters <g>.
>
>
Oops, I meant default values for template value parameters.
|
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lutger | Lutger wrote: > Walter Bright wrote: >> http://www.digitalmars.com/d/template-comparison.html >> >> Comments? > > Informative chart, links to spec and other articles about templates might be useful. > > Not sure if these belong to the chart, but I find the following features quite valuable with or in conjunction with templates: > > - Static assert, a no-brainer. > - Compile time messages, with static assert for example. I guess this by virtue of the .mangleof property with compile time string parsing? (I'm thinking of Don Clugston's meta.nameof library). Anyway the ability to easily give meaningful and readable error messages without resorting to compiler output parsing like STLlift can be a big time-saver. > - 'is' expressions All of these together give a large part of the functionality of C++0x concepts. void remove_if(T)(T start, T end) { static assert(isForwardIterator!(T), prettytypeof!(T) ~ " is not a forward iterator"); ... } > - templated mixins |
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> http://www.digitalmars.com/d/template-comparison.html
>
> Comments?
> Member Templates, D: yes
their allowed?
>Redeclaration of Template Parameter
is that a good thing?
what about mixins?
|
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lionello Lunesu | Lionello Lunesu wrote:
> !!?! I just did a reload of the page and now it's OK!
I bet your browser was caching the style sheet. The page requires an updated style.css for the code blocks.
|
January 19, 2007 Re: Comparison chart of D and C++ templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > In the "Pointer parameters" row, you might also want to add "delegates" to the D column, and make some mention of that ability in the "Pointer to member parameters" row (i.e. "No, D doesn't have pointers to parameters, it has delegates instead"). Good call. > This table also makes some things clear that would be nice to have in D. The ones that jump out at me are templated constructors and overloading templated functions with other functions. Templated constructors, yes, but the overloading thing is unnecessary and makes things more complicated than needed. |
Copyright © 1999-2021 by the D Language Foundation