2012/2/14, Sven Barth <pascaldra...@googlemail.com>: > Am 14.02.2012 06:45, schrieb Carver413: >> doesn't generics more or less duplicate the class every time you use it >> with >> different type, and if so would this not cause alot of bloating ? > > Yes it does. So for embedded systems "use with care" ;)
Oh, that is bad! C++ templates generate lots of duplicate code. Java's generics do not because it is just "syntactic sugar" allowing the compiler to check types which IMO is enough for most purposes. You don't need ugly type-casts but code-generation is not affected. Perfect. I know Delphi's and FPC's generics are different but I believed the compiler is clever enough to use the same class when possible. For example, in all cases where objects inherited from TObject are stored in a container, the same container could be used. This indirectly answered another question I had in mind: Does a generics container for a char or integer use the minimum needed amount of memory? I guess it does when a new instance of the container class is generated. Juha _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal