Is "class operator enumerator” supposed to work or is this a bug that it 
compiles but doesn’t do anything? Seems like it should work.

===========================

{$mode objfpc}
{$modeswitch advancedrecords}

program test;

type
  TArrayEnumerator = class
    public type
      TArrayValue = integer;
    public
      function GetCurrent: TArrayValue;
      constructor Create(a: pointer);
      property Current: TArrayValue read GetCurrent;
      function MoveNext: Boolean;
  end;
  TRec = record
    class operator enumerator(a: TRec): TArrayEnumerator;
  end;

class operator TRec.Enumerator(a: TRec): TArrayEnumerator;
begin
  result := TArrayEnumerator.Create(@a);
end;

function TArrayEnumerator.GetCurrent: TArrayValue;
begin
end;

constructor TArrayEnumerator.Create(a: pointer);
begin
end;

function TArrayEnumerator.MoveNext: Boolean;
begin  
end;

var
  arr: TRec;
  value: integer;
begin
  for value in arr do   // <<<< ERROR: Cannot find an enumerator for the type 
"TRec"
    begin
    end;
end.


Regards,
        Ryan Joseph

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

Reply via email to