[fpc-pascal] Re: TLinkedList

Sven Barth pascaldragon at googlemail.com
Wed Feb 15 15:14:33 CET 2012


Am 15.02.2012 15:09, schrieb michael.vancanneyt at wisa.be:
>
>
> On Wed, 15 Feb 2012, Sven Barth wrote:
>
>> Am 15.02.2012 14:09, schrieb michael.vancanneyt at wisa.be:
>>>
>>>
>>> On Wed, 15 Feb 2012, Sven Barth wrote:
>>>
>>>> Am 14.02.2012 22:28, schrieb Marco van de Voort:
>>>>> 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?
>>>>
>>>> That wouldn't change that much... the performance of specialized
>>>> generics isn't that different from "normal" code.
>>>
>>> I tested that. It's about 10% slower.
>>
>> Compile time or runtime?
>
> Runtime.

Then this might be because the current generic classes are written in a 
rather generic way (no pun intended). This might improve once 
constraints are implemented and generics for specific subtypes (e.g. the 
TFPGObjectList) can be implemented more efficiently.

Regards,
Sven



More information about the fpc-pascal mailing list