What's the difference between: type polymorphism parametric polymorphism ad-hoc polymorphism generics c++ templates d style templates other templates (are there?)
Does Java and C# have type polymorphism or generics or templates? What's the real name and how to compare? Is D most expressive? I bet it is. - G.W. Paulo Pinto Wrote: > Sorry but I still don't get it. > > Do you mean that the types that erased and the same code is generated? > > Then let me say that .Net generics get generated on the fly and JITed for > each > different type. > > Eiffel and Modula-3 generics also have specific generated code for each > type. > > The major difference regarding C++ code is that the linkers are smarter and > are > able to remove duplicates of the generated code for the same set of type > arguments. > > -- > Paulo > > "Jonathan M Davis" <jmdavisp...@gmx.com> wrote in message > news:mailman.755.1287643587.858.digitalmar...@puremagic.com... > > On Wednesday 20 October 2010 22:47:15 Paulo Pinto wrote: > >> Eiffel does have templates, as in generic types. > >> > >> Or do you mean the compile time trick that C++ templates allow, thus > >> opening the door for > >> the meta programming done at compile time? > > > > Templates and generics are two separate - albeit related - things. > > Templates > > generate code whereas generics allow you to use multiple types with the > > same > > code (be it by generating code or by actually making them share code). C++ > > templates happen to allow for metaprogramming beyond that, but I don't > > think > > that that's necessary for a language to be considered to have templates. > > The key > > thing is that templates _generate_ code whereas generics can simply make > > multiple types use the same code. C++ and D are the only languages that > > I'm > > aware of which have templates. Other languages with generics generally > > don't use > > templates to have generics. > > > > - Jonathan M Davis > >