Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2024-06

Is that valid? property using function with extra args...

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

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.

Reply by email