Why Templates?

Bruno Medeiros daiphoenixNO at SPAMlycos.com
Sun Mar 5 16:09:35 PST 2006


Hasan Aljudy wrote:
> Walter Bright wrote:
>> "Ivan Senji" <ivan.senji_REMOVE_ at _THIS__gmail.com> wrote in message 
>> news:duf72h$f40$1 at digitaldaemon.com...
>>
>>> Maybe so, but I see a common Object base class a hack to solve many 
>>> problems that are simple and efficient to solve with templates. For 
>>> example containers. Containers in Java(before templates)-style and 
>>> C#(before templates)-style are nothing but inefficient hacks.
>>
>>
>> Technically, Java and C# implement generics, not templates. C++ and D 
>> implement templates, not generics.
>>
>> What's the difference? One way to think about it is generics are 
>> handled at run time (by casting), templates at compile time.
>>
> 
> Are you saying that all generics do is silently insert casts?

For all interested, here's an article that explains the differences in 
more detail:
http://www-128.ibm.com/developerworks/library/j-jtp01255.html
This was posted in the NG by someone else that I don't recall, some time 
ago.


-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list