Recent

Author Topic: FPC generics: circular type reference?  (Read 4208 times)

serge_t

  • New Member
  • *
  • Posts: 10
FPC generics: circular type reference?
« on: March 10, 2015, 04:24:39 pm »
Hello,

Is it possible to implement the circular type reference within the generic type?
Following example doesn't compile with FPC 2.6.4 (Lazarus 1.2.6 Win32).

Code: [Select]
  generic TGItem<T> = class
  private type
    TGItemSpec = specialize TGItem<T>;
  private var
    FValue: T;
    FLeft, FRight: TGItemSpec;
  public
    property Value: T read FValue write FValue;
  end;

Code: [Select]
project1.lpr(7,29) Error: Illegal expression
project1.lpr(7,35) Error: Specialization is only supported for generic types

Blaazen

  • Hero Member
  • *****
  • Posts: 3239
  • POKE 54296,15
    • Eye-Candy Controls
Re: FPC generics: circular type reference?
« Reply #1 on: March 10, 2015, 05:20:19 pm »
Your code compiles well in 3.1.1 (only Note: private fields FLeft, FRight never used). There were many generic improvements that are not included in 2.6.4 yet.
Use trunk or wait for fpc 3.0.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

serge_t

  • New Member
  • *
  • Posts: 10
Re: FPC generics: circular type reference?
« Reply #2 on: March 10, 2015, 05:30:22 pm »
Thank for response.
 
Is it possible to use FPC 3.x with Lazarus?
We have many applications built with LCL so migrating is required in this case.

Blaazen

  • Hero Member
  • *****
  • Posts: 3239
  • POKE 54296,15
    • Eye-Candy Controls
Re: FPC generics: circular type reference?
« Reply #3 on: March 10, 2015, 06:09:06 pm »
Yes, Lazarus trunk works with FPC trunk.

See my footer: Lazarus 1.5 r48240M FPC 3.1.1 30069 x86_64
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

serge_t

  • New Member
  • *
  • Posts: 10
Re: FPC generics: circular type reference?
« Reply #4 on: March 11, 2015, 10:47:24 am »
Ok, we will waiting for 1.5 release  :)

P.S. Generic tree implementation for FPC 2.6.4 without circular type references is here
http://arbinada.com/main/node/1430
« Last Edit: May 27, 2015, 04:38:25 pm by serge_t »

 

TinyPortal © 2005-2018