[fpc-devel] [] property overloads
Ondrej Pokorny
lazarus at kluug.net
Mon Jul 1 21:33:14 CEST 2019
On 01.07.2019 21:04, Michael Van Canneyt wrote:
>> If the compiler encounters "Mytest.StringArray" it can be evaluated
>> only as the non-indexed overload.
>
> Well... We can of course discuss forever, and still not agree.
> I suggest we let the compiler people have the last word on this. They
> know best. And if you turn out to be right: so much the better.
Yes - either I don't see something obvious here or you :)
But I really don't know a situation where
Mytest.StringArray;
(without the []-brackets) is valid syntax for an array property:
TTest = class
public
property StringArray[Index: Integer]: string read GetString;
end;
- and if such a code is always invalid there is free space for the
non-indexed overload. Or can you think of some valid code where an
indexed (array) property can be accessed without the []-brackets?
It's basically the same as method overloads:
TTest = class
public
procedure Test(index: integer);
procedure Test;
end;
Only the brackets change from [] to ().
Yes, there is the new situation when the non-indexed overload is an
array itself (or is an object with a default property) - but this can be
solved by simply saying that the indexed property has precedence before
resolving the array of the non-indexed property.
Ondrej
More information about the fpc-devel
mailing list