[fpc-pascal] Re: TLinkedList
Juha Manninen
juha.manninen62 at gmail.com
Sun Feb 12 08:37:04 CET 2012
2012/2/11, Jorge Aldo G. de F. Junior <jagfj80 at 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
More information about the fpc-pascal
mailing list