[fpc-pascal] Re: TLinkedList

Jorge Aldo G. de F. Junior jagfj80 at gmail.com
Wed Feb 15 01:05:36 CET 2012


i once read a textbook about generics (C++ generics) showing how C++
code can end up being FASTER than C equivalent due to lack of type
checks...

it uses a quick sort routing as example.

on C you end up having to check the type of storage to get a similar
result, while on C++ you check this at runtime. it was something along
that lines.

the point being made was that object orientation is not necessarely
"bloat" but leads to better written code. (not always true, but...)

2012/2/14 Marco van de Voort <marcov at stack.nl>:
> In our previous episode, Sven Barth said:
>> > Afaik it was the main reason to implement generic constraints in Delphi (like
>> > .NET)?
>>
>> Constraints allow the compiler to infer further information on the given
>> types to improve e.g. type checking when parsing the generic,
>
> Exactly. You e.g. know that the unspecialized generic is already meant for
> reference types, from line one.
>
>> but they won't magically allow the compiler to not duplicate code (in
>> theory it would be possible to do something like Java's generics for cases
>> where the constraints are for descendants of TObject or IInterface, but in
>> my opinion the tradeoffs (increased compiler complexity) are not worth
>> it).
>
> Yeah, that is typical. If it is not used inside the compiler it is
> unoptimized :-)
>
> Maybe redo cclasses with generics?
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list