[fpc-devel] indexed property with default value for param?

Martin Friebe fpc at mfriebe.de
Thu Jun 11 14:14:16 CEST 2009

Michael Van Canneyt wrote:
> On Wed, 10 Jun 2009, Martin wrote:
>> However the follwing Syntax compiles fine:
>> function GetFoo(Bar: integer; XY: Boolean = True): Integer;
>> property Foo[Bar: integer; XY: Boolean] read GetFoo;
>> a := Object.Foo[1];
>> But:
>> Is that supposed to work?
> No, it is not. It is a compiler bug. Could you please create a bug 
> report?

However it would be nice to have a feature like

    property Foo[Index: Integer]: Integer  write SetFoo  read GetFoo;
    property Foo[Index: Integer; Ask: Boolean]: Integer  write 
SetFooAsk   read GetFooAsk;

The must have different Method Names, because the Setters(write SetFoo) 
last argument is the Value, so it' can not have a optional Ask element:
  procedure WrongSetFoo(Index: Integer; Ask: Boolean= True; AValue: 
But with different Setter/Getters that would not be a problem. In fact 
they can have the same name, if they are overloaded.

Any idea if such a feature would have a chance?

Best Regards

More information about the fpc-devel mailing list