The below compiles, and writes
1 2

Are indexes to properties intentionally allowed to take "var param"?
Btw it even compiles with an "out" param.


program Project1;
type

  { TFoo }

  TFoo = class
  private
    function GetFoo(var AIndex: Integer): Integer;
  public
    property Foo[var AIndex: Integer]: Integer read GetFoo;
  end;

{ TFoo }

function TFoo.GetFoo(var AIndex: Integer): Integer;
begin
  Result := AIndex;
  AIndex := AIndex+1;
end;

var a,i: integer;
  f: TFoo;
begin
  f := TFoo.Create;
  i := 1;
  a := f.Foo[i];
  writeln(a,' ',i);
  readln;
end.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to