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

Martin fpc at mfriebe.de
Wed Jun 10 23:00:13 CEST 2009


Procedures/Functions can have default values for arguments, so they 
don't need to be specified if called
  function GetFoo(Bar: integer; XY: Boolean = True): Integer;

Properties (indexed) don't have such a syntax:
  property Foo[Bar: integer; XY: Boolean = True] read GetFoo;
will give an error

However the follwing Syntax compiles fine:
  function GetFoo(Bar: integer; XY: Boolean = True): Integer;
  property Foo[Bar: integer; XY: Boolean] read GetFoo;

and then you can do:
  a := Object.Foo[1];

But:
Is that supposed to work?

Because it can not be done for write access, as the last argument it the 
value to be assigne, and that doesn't have a default value. And even if 
it had, it requred the correct position => that is *all* param present.

Martin



More information about the fpc-devel mailing list