[fpc-pascal] Generics problem/question

Aleksa Todorovic alexione at gmail.com
Mon Jan 18 13:07:02 CET 2010


On Fri, Jan 15, 2010 at 09:00, leledumbo <leledumbo_cool at yahoo.co.id> wrote:
>
> Ah... I can see it now:
>
> 711  function TFPGList.IndexOf(const Item: T): Integer;
> 712  begin
> 713    Result := 0;
> 714    {$info TODO: fix inlining to work! InternalItems[Result]^}
> 715    while (Result < FCount) and (PT(FList)[Result] <> Item) do
> 716      Inc(Result);
> 717    if Result = FCount then
> 718      Result := -1;
> 719  end;
>
> This is where the = operator is required (<> is derived from = ).
>
> I continue the discussion in mantis, so that this can be solved (hopefully).

I've attached patch to mantis bug which makes compiler print error
about missing operator "TPar" = "TPar". This could, at least, give
user some hint about what is wrong.

The proper solution for this problem is not simple. Somehow, you will
have to make operator = (const A, B: TPar) visible inside FGL unit
(because of the way generics are currently implemented), or make
compiler think that TPGList is implemented in the place where
specialization occurs (so compiler first searches "specialization
space", and after that "generic-declaration space").



More information about the fpc-pascal mailing list