[fpc-devel] Generics

Florian Klaempfl florian at freepascal.org
Sun Apr 9 22:02:44 CEST 2006


Flávio Etrusco wrote:
> On 4/9/06, Florian Klaempfl <florian at freepascal.org> wrote:
>> Flávio Etrusco wrote:
>>> On 4/9/06, Florian Klaempfl <florian at freepascal.org> wrote:
>>>> rstar at mnet-online.de wrote:
>>>> (...)
>>>> Is there already a specification how they will look like in Delphi?
>>>>
>>>>> (.net2)? What's planned? Can somebody explain?
>>>>>
>>>> They are more like C++ templates.
>>> What? Do you mean that FPC implementation of generics wouldn't be
>>> based on "type erasure" but on beefed-up-precompiler-macros? Please
>>> say I got it all wrong :-o
>> You want crippled generics regarding speed and usage like C# has? You
>> can do this with "real" templates as well using an implementation class
>> and wrapper templates.
> 
> I've never heard any critics/complaints on the performance of generics
> in Java (I'm not much into .net 2 yet), but you certainly know better
> than me.

Well, talking about Java's speed never makes sense. Fact is, if you use
classes that you've always an indirection because of the pointer and
extra memory manager overhead while for simple tasks you can use simple
embed the data into the container data when using real templates.

> I guess I was a bit too hasty on the whining, but just thinking about
> C++ compilation speed when using templates give me cries... 

This has nothing to do with templates.

> TBH I
> never tried using "type erasure" in C++ templates, but I remember C++
> templates' inner workings to have enough pitfalls for me to want to
> avoid templates at all costs...
> 



More information about the fpc-devel mailing list