Sign in Join

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

Mailing lists / fpc-devel / 2010-06

Specialized Generic for Structures with Abstract Methods

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Andrew Brunner

In uGenerics I have two lists. 1 for Data Structures and 1 for Objects.

If I place this statement in declarations for a system that handles an Int64 List...

     GInt64List=specialize GStructList<Int64>;

... then I get

C:\Developer\Source\Libraries\Core\uInt64Array.pas(54,17) Error:
Forward declaration not solved "GStructList$Int64.Empty(var Int64);"

For the most part I want to have a generic case for data structures with the list object handling init, copy,empty,and done methods for the elements.

I am using FPC from today's trunk and wanted to know if there is something wrong with generics that I can't use abstract methods for my generic and just populate the methods "AFTER" I specialize...

  GInt64List=specialize GStructList<Int64>;
  TInt64List=Class(GInt64List)
  public
    procedure Empty(Var Item:Int64); override;
    procedure Done(Var Item:Int64);override;
    procedure Init(Var Item:Int64);override;
  end;

I'm getting compiler errors b/c abstractions ... The way I've used generics in FPC is that I preface my generic types with "G"... Then I descend from that class the actual class I want to use.

Can the current FPC be worked to make this happen or do I need to submit a report?

Reply by email

Micha Nelissen
to Andrew Brunner
Andrew Brunner wrote
... then I get C:\Developer\Source\Libraries\Core\uInt64Array.pas(54,17) Error: Forward declaration not solved "GStructList$Int64.Empty(var Int64);"

Please always provide a complete compilable example.

Micha

Reply by email

Andrew Brunner
to Micha Nelissen

I provided a working example. Just employ uGenerics in a project and declare

 GInt64List=specialize GStructList<Int64>;
 TInt64List=Class(GInt64List)
 public
   procedure Empty(Var Item:Int64); override;
   procedure Done(Var Item:Int64);override;
   procedure Init(Var Item:Int64);override;
 end;

and see the errors.

Did the uGenerics unit get dropped by the mailer daemon?

Micha Nelissen wrote 14 lines
Andrew Brunner wrote: > > ... then I get > > C:\Developer\Source\Libraries\Core\uInt64Array.pas(54,17) Error: > Forward declaration not solved "GStructList$Int64.Empty(var Int64);" Please always provide a complete compilable example. Micha _______________________________________________ fpc-devel maillist  -   http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email