[fpc-pascal] Re: TLinkedList

Sven Barth pascaldragon at googlemail.com
Tue Feb 14 22:10:55 CET 2012


On 14.02.2012 22:03, Marco van de Voort wrote:
> In our previous episode, Sven Barth said:
>>> in a container, the same container could be used.
>>
>> Such logic unnecessarily complicates the compiler. Generics are already
>> troublesome enough.
>
> 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, 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).

Regards,
Sven



More information about the fpc-pascal mailing list