[fpc-devel] Generics

Micha Nelissen micha at neli.hopto.org
Wed Apr 12 18:18:15 CEST 2006


On Wed, 12 Apr 2006 08:31:58 +0200 (CEST)
"Peter Vreman" <peter at freepascal.org> wrote:

> FPC is a compiled language where not all types are classes. The only way
> to implement it is like C++ templates. It is a known fact that generics
> will introduce code bloat, but that is still less than the 15-20mb virtual
> machines you need for Java/C#

Those 'bloat's are not really comparable because they have a different
origin. 

With templates you can prevent bloat by designing/implementing your data
structure with a size parameter, then the generic descendent will only be a
bunch of inlined typecasts -> no bloat. Of course, the generic size
parameter may waste memory and/or CPU cycles, but that's exactly where the
tradeoff has to be made anyway.

Micha



More information about the fpc-devel mailing list