[fpc-devel] Generics Basics
Peter Vreman
peter at freepascal.org
Thu Nov 10 09:37:11 CET 2005
>> There's a big risk involved with templates; code bloat. Namely, with
>> templates, you can instantiate classes without realising that you are
>> adding tens of kilobytes of code.
>>
>> I.e. in C++ if you instantiate a vector<class_a *>, vector<class_b *>,
>> vector<class_c *>, you have three implementations of the vector in your
>> code, which are all an array of pointers! Surely Pascal's
>> Tcollection/Tlist is much more efficient.
>
> Won't the compiler sometimes be able to handle this smarter? When the code
> generated for vector<TClassA> and vector<TClassB> is equivalent, we only
> need to include it once in the resulting executable, right? The only thing
> is we have to see when this situation occurs.
Lets first get basic things working before thinking about optimization.
The whole generic thing is not as easy to implement as you can describe it
in normal words.
More information about the fpc-devel
mailing list