Recent

Author Topic: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED  (Read 6602 times)

ExSystem

  • New Member
  • *
  • Posts: 19
【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« on: March 09, 2016, 08:48:16 am »
http://bugs.freepascal.org/view.php?id=24283

would this get to be fixed? :o

or, let me do it? :D

balazsszekely

  • Guest
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #1 on: March 09, 2016, 10:50:28 am »
According to the bug report it's not fixed(not even assigned to a developer),  so feel free to create a patch :P. The beer is on me if you can do it.

ExSystem

  • New Member
  • *
  • Posts: 19
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #2 on: April 11, 2016, 04:48:50 am »
btw, is there any workaround for this?

Code: Pascal  [Select][+][-]
  1. IFoo<T> = Interface(IInterface) //YES, interface, NOT class
  2.   Procedure Bar(AFoo: ISomeList<TSomeClass<T>>); //SEE ISomeList<TSomeClass<T>>
  3. End;
  4.  
« Last Edit: April 11, 2016, 04:52:06 am by ExSystem »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #3 on: April 11, 2016, 07:35:35 am »
btw, is there any workaround for this?

Code: Pascal  [Select][+][-]
  1. IFoo<T> = Interface(IInterface) //YES, interface, NOT class
  2.   Procedure Bar(AFoo: ISomeList<TSomeClass<T>>); //SEE ISomeList<TSomeClass<T>>
  3. End;
  4.  
What workaround? Please describe the problem along with full short compilable code. This:
Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2.  
  3. type
  4.   TSomeClass<T> = class
  5.   end;
  6.  
  7.   ISomeList<T> = interface
  8.   end;
  9.  
  10.   IFoo<T> = Interface(IInterface) //YES, interface, NOT class
  11.     Procedure Bar(AFoo: ISomeList<TSomeClass<T>>); //SEE ISomeList<TSomeClass<T>>
  12.   End;
  13.  
  14. begin
  15. end.
  16.  
Compiles.

ExSystem

  • New Member
  • *
  • Posts: 19
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #4 on: April 11, 2016, 08:22:23 am »
This does compile in DELPHI, but NOT in FPC(mine is ver 3.0.0). <-- This is the exactly problem.


btw, is there any workaround for this?

Code: Pascal  [Select][+][-]
  1. IFoo<T> = Interface(IInterface) //YES, interface, NOT class
  2.   Procedure Bar(AFoo: ISomeList<TSomeClass<T>>); //SEE ISomeList<TSomeClass<T>>
  3. End;
  4.  
What workaround? Please describe the problem along with full short compilable code. This:
Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2.  
  3. type
  4.   TSomeClass<T> = class
  5.   end;
  6.  
  7.   ISomeList<T> = interface
  8.   end;
  9.  
  10.   IFoo<T> = Interface(IInterface) //YES, interface, NOT class
  11.     Procedure Bar(AFoo: ISomeList<TSomeClass<T>>); //SEE ISomeList<TSomeClass<T>>
  12.   End;
  13.  
  14. begin
  15. end.
  16.  
Compiles.

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #5 on: April 11, 2016, 10:38:00 am »
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2.  
  3. Type
  4.    generic IFoo<T> = Interface(IInterface)
  5. ...
  6.  

In objfpc mode, you need to add generic keyword in before your type.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #6 on: April 11, 2016, 10:59:39 am »
It compiles with 3.1.1 but not with 3.0.0:


Code: Pascal  [Select][+][-]
  1. C:\testing>fpc gtst
  2. Free Pascal Compiler version 3.1.1 [2016/03/23] for i386
  3. Copyright (c) 1993-2016 by Florian Klaempfl and others
  4. Target OS: Win32 for i386
  5. Compiling gtst.pp
  6. gtst.pp(4,14) Note: Private type "TSomeClass$1.T" never used
  7. gtst.pp(7,13) Note: Private type "ISomeList$1.T" never used
  8. Linking gtst.exe
  9. 14 lines compiled, 0.1 sec, 26928 bytes code, 1300 bytes data
  10. 2 note(s) issued
  11.  
  12. C:\testing>dorel
  13.  
  14. C:\testing>fpc gtst
  15. Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
  16. Copyright (c) 1993-2015 by Florian Klaempfl and others
  17. Target OS: Win32 for i386
  18. Compiling gtst.pp
  19. gtst.pp(11,45) Fatal: Syntax error, "," expected but "<" found
  20. Fatal: Compilation aborted
  21. Error: C:\fpc\3.0.0\bin\i386-win32\ppc386.exe returned an error exitcode
  22.  

Cyrax:  he has a $mode delphi in place.

The objfpc code is

Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2.  
  3. type
  4.  generic  TSomeClass<T> = class
  5.   end;
  6.  
  7.  generic  ISomeList<T> = interface
  8.   end;
  9.  
  10.   generic IFoo<T> = Interface(IInterface) //YES, interface, NOT class
  11.     Procedure Bar(AFoo: specialize ISomeList<specialize TSomeClass<T>>); //SEE ISomeList<TSomeClass<T>>
  12.   End;
  13.  
  14. begin
  15. end.

And I know I know why I hate the FPC syntax again, but also in this case only 3.1.1 works, 3.0.0 not:

Code: [Select]

C:\testing>fpc gtst
Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling gtst.pp
gtst.pp(11,46) Error: Identifier not found "specialize"
gtst.pp(11,57) Error: Type identifier expected
gtst.pp(11,57) Fatal: Syntax error, "," expected but "identifier TSOMECLASS" found
Fatal: Compilation aborted
Error: C:\fpc\3.0.0\bin\i386-win32\ppc386.exe returned an error exitcode
« Last Edit: April 11, 2016, 11:03:00 am by marcov »

ExSystem

  • New Member
  • *
  • Posts: 19
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #7 on: April 11, 2016, 03:19:30 pm »
 :) :) :)
great, I start deleting a bunch of {$IFDEF FPC} .. {$ELSE} .. {$ENDIF} blocks now. No more IPairXXX<K, V>, but just IXXX<TPair<K, V>> now...

And i think, in objfpc mode, just copy the forms of C++, JAVA, C# in generics grammar is fine...
« Last Edit: April 11, 2016, 03:33:49 pm by ExSystem »

ExSystem

  • New Member
  • *
  • Posts: 19
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #8 on: April 16, 2016, 04:36:03 pm »
AFTER UPGRADING FPC TO 3.1.1:

A new bug found related to GENERICS.  :o

Code: Pascal  [Select][+][-]
  1. Unit XFramework.Acl;
  2.  
  3. {$IFDEF FPC}
  4. {$mode delphi}{$H+}
  5. {$ENDIF}
  6.  
  7. Interface
  8.  
  9. Uses
  10.   XFramework.System, XFramework.Containers, // XFramework
  11.   SysUtils;
  12.  
  13. Type
  14.   // forward declaration - begin
  15.   TAcl<K, R, M> = Class;
  16.   // forward declaration - end
  17.  
  18.   // fake todo -begin
  19.   TClass<T> = Class
  20.   End;
  21.   // fake todo -end
  22.  
  23.   EAclException = Class(EException);
  24.   EResourceExisted = Class(EAclException);
  25.   ENoSuchParentResource = Class(EAclException);
  26.   ERoleExisted = Class(EAclException);
  27.   EMembershipExisted = Class(EAclException);
  28.   ENoSuchMembership = Class(EAclException);
  29.   ENoSuchParentRole = Class(EAclException);
  30.   ENoSuchRole = Class(EAclException);
  31.   ENoSuchResource = Class(EAclException);
  32.  
  33.   IRole = Interface(IInterface)
  34.     Function GetRoldId: String;
  35.     Property RoldId: String Read GetRoldId;
  36.   End;
  37.  
  38.   IResource = Interface(IInterface)
  39.     Function GetResourceId: String;
  40.     Property ResourceId: String Read GetResourceId;
  41.   End;
  42.  
  43.   TAssertion<K, R, M> = Function(Acl: TAcl<K, R, M>; Rold: IRole; Resource: IResource; Privilege: String): Boolean Of Object;
  44.  

LAST LINE, char 45(  TAssertion<K, R, M> = Function(Acl: TAcl<K<----HERE):   Error: Internal error 2015080101
« Last Edit: April 16, 2016, 04:42:41 pm by ExSystem »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: 【TFoo<K, V> = class(TBar<TPair<K, V>>)】NEEDED
« Reply #9 on: April 16, 2016, 04:53:43 pm »
LAST LINE, char 45(  TAssertion<K, R, M> = Function(Acl: TAcl<K<----HERE):   Error: Internal error 2015080101
http://wiki.lazarus.freepascal.org/Lazarus_Faq#.27Fatal:_Internal_error_XXXXYYZZW.27

ExSystem

  • New Member
  • *
  • Posts: 19

 

TinyPortal © 2005-2018