Am 30.06.2019 um 00:02 schrieb Martin Frb:
However this works:
=== code begin ===
function GetFoo(AIndex: Integer; BIndex: Integer = 0): Integer;
property Foo[AIndex: Integer; BIndex: Integer = 0]: Integer read GetFoo;
Ouch
What then about
function GetFoo(AIndex: Integer = 0): Integer;
property Foo[AIndex: Integer = 0]: Integer read GetFoo;
And if it compiles, which of those can you call
Obj.Foo
Obj.Foo[]
And what if you make that default property....
Obj[] // ????
Those all don't compile. Even using my example above "Foo[42]" does not
compile either, so while a default parameter can be declared the
compiler won't allow the default parameters to be left out in the index
clause.
Maybe we should forbid default parameters in the index clause in
non-Delphi modes so that it's clear that this won't work?
As does this:
=== code begin ===
function GetFoo(AIndex: Integer; BIndex: Integer = 0): Integer;
property Foo[AIndex: Integer; BIndex: Integer]: Integer read GetFoo;
This is ok.
GetFoo can be called directly.
So long, as the property will fail, if called with only one index.
Yes, it indeed fails.
Regards,
Sven
_______________________________________________
fpc-devel maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel