2012/2/11, Jorge Aldo G. de F. Junior <jagf...@gmail.com>:
> I believe generics makes faster code due to having no need to test
> types during runtime... i maybe wrong.

It is true only if you use the type-safe "as" casting. Normal casting
does not check types at runtime.
It does make the code more readable. Like:
  MyVar := MyList[i];
compared to
  MyVar := TMyType(MyList[i]);

Also, you get compile time type-checking, just like arrays had from day 1.
The code is safer, more readable and self-documenting.

I hope there will be a good and comprehensive generics container
library. Now the containers are scattered around and are competing
with each other.
Java serves as a good example here. It has a consistent generics
container library. Classes are easy to find and use.

Juha
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to