[fpc-devel] Which of them are right (Delphi or FPC)

Amir Aavani Aavani at iust.ac.ir
Tue Apr 18 07:51:35 CEST 2006


I developed a project in lazarus (FPC) and now when I try to run it in 
Delphi, it acts incorrect!

I have a class TObjectCollection which is a collection of TObject:
 TObjectCollection= class (TObject)
      FMembers: array of TObject;
       ...
        ...
    public
      property Member [Index: Integer]: TObject read GetMember;
      ...
      procedure Add (ANewMember: TObject);
      ...
  end;

And A TObject1Collection which is like this:
 TObject1Collection= class (TObjectCollection)
      function GetMember: TObject1;
       ...
        ...
    public
      property Member [Index: Integer]: TObject1 read GetMember;
      ...
      procedure Add (ANewMember: TObject1);
      ...
  end;

procedure TObject1Collection.Add (ANewMember: TObject1);
begin
  (Self AS TObjectCollection).Add (ANewMember AS TObject);
end;

procedure TObject1Collection.GetMember: TObject1;
begin
  Result:= (Self AS TObjectCollection).Member AS TObject1;end;
end;

The code works correctly in lazarus, but in Delphi, the procedure 
TObject1Collection.Add call itself instead of TObjectCollection.Add. I 
changed the code like this:
  SelfAsTObjectCollection:= Self As TObjectCollection;
  SelfAsTObjectCollection.Add (ANewMember);
and the problem solved.
I want to know, which of us (me, Delphi, Freepascal) is wrong.





More information about the fpc-devel mailing list