Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-03

Objfpc and generics duplicate identifier

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Maciej Izak

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

Reply by email

Sven Barth
to Maciej Izak
Maciej Izak wrote 35 lines
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:

This is by design to allow backwards compatiblity with older generic code. Maybe I'll add a modeswitch somewhen though to allow this in mode ObjFPC as well...

Regards,
Sven

Reply by email