Below compiles (3.2.3). Should it?

Note the extra argument in "GetFoo". It only works because it has a default.

program Project1;
type
  tf = class
  private
    function GetFoo(AIndex: Integer; b: integer = 2): char;
  public
    property Foo: char index 1 read GetFoo;
  end;

function tf.GetFoo(AIndex: Integer; b: integer): char;
begin
end;

begin
end.


---------
On that note,
if instead the correct amount of params was given:

    function GetFoo(AIndex: Integer= 2): char;

But with a default, should that work.
It does, and IMHO it is ok to work.

If used by the property, then a value is always given and the default never matters.
But if called directly, the default can be used.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to