[fpc-devel] Templates / Generics

Peter Vreman peter at freepascal.org
Fri Nov 4 19:33:03 CET 2005


At 18:17 4-11-2005, you wrote:
>This is evaluated by the pre-compiler run during compile time.
>
>When you use the template with e.g.
>var
>bl: List<String>;
>
>then procedure show(s:string) is taken.
>

But what if the bl: List<String> is called from an other unit? The 
Show(string) is then not visible anymore?




>Peter Vreman wrote:
>
>>>Mattias Gaertner wrote:
>>>
>>>
>>>
>>>>This page looks only like the start of a proposal. Neither complete nor
>>>>official.
>>>>Why do you think, that D2006 will have generics?
>>>>
>>>>
>>>>
>>>>
>>>D2006 <> D11=D2007
>>>
>>
>>How will Delphi handle the following case with overloads and different types:
>>
>>
>>
>>unit test;
>>
>>interface
>>
>>type
>>  List<T> = class
>>    data : T;
>>    constructor(aData: T);
>>    procedure dump;
>>  end;
>>
>>implementation
>>
>>procedure show(i:integer);overload;
>>begin
>>end;
>>
>>procedure show(s:string);overload;
>>begin
>>end;
>>
>>constructor List<T>(aData: T);
>>begin
>>  Data := aData;
>>end;
>>
>>procedure List<T>.Dump;
>>begin
>>  Show(Data);
>>end;
>>
>>end.
>>
>>
>>_______________________________________________
>>fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>>http://lists.freepascal.org/mailman/listinfo/fpc-devel
>>
>>
>>
>
>_______________________________________________
>fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>http://lists.freepascal.org/mailman/listinfo/fpc-devel

Peter




More information about the fpc-devel mailing list