Hy All! :)

Hy All! :)

Is there any way to make a record helper for TPair?

For example:

type
  TData = TPair;
  TDataHelper = record helper for TData
// Error here: [DCC Error] something.pas(xx): E2086 Type 'TPair' is not yet completely defined
    function IncValue: Integer;
  end;

function TDataHelper.IncValue: Integer;
begin
  Inc(Value);
  Result := Value;
end;

Comments

  1. IncValue() in error message and IncInteger() in code below? typo or mistake?

    ReplyDelete
  2. try to put TData and TDataHelper in different Type-sections, seems it works fine (at least in xe2);


    type
       TData = TPair;
    type
       TDataHelper = record helper for TData
       end;

    ReplyDelete
  3. Thx, it was a typo, modified:
    function TDataHelper.IncInteger: Integer;
    to
    function TDataHelper.IncValue: Integer;

    ReplyDelete
  4. Andrew Terekhov Thank You, it works in XE too! :)

    What is the difference in approach of the compiler, Marco Cantù ?

    ReplyDelete
  5. +1 to Andrew Terekhov answer, but who can desribe that? This is very strange.

    ReplyDelete
  6. I ran across this too when messing around in earlier Delphi versions. It's fixed in XE6 at least, perhaps earlier.

    ReplyDelete

Post a Comment