[fpc-devel] Objfpc and generics duplicate identifier

Maciej Izak hnb.code at gmail.com
Sat Mar 23 00:50:56 CET 2013


Hi,

I started to implement Generics.Collections in FreePascal
(successfully!). I wanted to start using objfpc, but I have a problem
with generics in fpcobj mode. In Delphi mode i don't have any problems
with my implementation. For example:

type
  IEnumerable = interface
  end;

  IEnumerable<T> = interface
  end;

  IEnumerable<T1, T2> = interface
  end;

in fpcobj:

type
  IEnumerable = interface
  // ? generic IEnumerable<> = interface
  end;

  generic IEnumerable<T> = interface // Error: Duplicate identifier
"IEnumerable$1"
  end;

  generic IEnumerable<T1, T2> = interface // Error: Duplicate
identifier "IEnumerable$2"
  end;

I think it is a big problem... Especially for future usage of
anonymous methods (when/if they are implemented)... Example from
Delphi:

type
  TProc = reference to procedure;
  TProc<T> = reference to procedure (Arg1: T);
  TProc<T1,T2> = reference to procedure (Arg1: T1; Arg2: T2);
  TProc<T1,T2,T3> = reference to procedure (Arg1: T1; Arg2: T2; Arg3: T3);

etc.

Regards,
HNB



More information about the fpc-devel mailing list