Hi,

is there way how to declare function, which will accept as parameter any array type ?
(this parameter I need forward to System.Length() only )

Just like Length() function.

Now I fall into problem with generics , where I have in one unit generic object, which has Length property (or Length function)
This function internally calls System.Length(A)

But when I specialize such generic in another unit, I give "Compilation aborted" (FPC 2.6.4)

Culprit is prefix "System.".

When I omit prefix "System." then I give another error: Wrong number of parameters specified for call to "Length"
(compiler is probably recognizing "Length" of object )

Example:

-----------------------------------------------------------------------------

1st unit:

  generic GT<T> = object
    private
      var
        FArray: array of T;
        Fx, Fy: integer;
      function GetLength: integer;
    public
      type
        TElement = T;
        PElement = ^T;
      constructor Init; overload;
      constructor Init(x,y: integer); overload;
      property Length: integer read GetLength;
  end;

function T2DArray.GetLength: integer;
begin
Result := System.Length(FArray); // <-- HERE prefix System is causing "Compilation aborted" in FPC 2.6.4
end;

-----------------------------------------------------------------------------

2nd unit:

T2DIntArray = object(specialize GT<Integer>) end;

-----------------------------------------------------------------------------

Is there any workaround ?

Thanks

L.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to