On Mon, 1 Jul 2019, Ondrej Pokorny wrote:
On 01.07.2019 18:21, Michael Van Canneyt wrote:
On Mon, 1 Jul 2019, Ondrej Pokorny wrote:
On 01.07.2019 15:57, Ryan Joseph wrote:
Yes, I’ve made a patch to allow overriding the actual property
(https://bugs.freepascal.org/view.php?id=35772).
Very good! Just a short question: does your solution allow one
overload without array indexes? It is very useful as a for-in
enumerator of the array property:
TTest = class
public
// ...
property StringArray[Index: Integer]: string read GetString;
property StringArray: TTestObjectEnumerator read GetString;
end;
I really don't think this should be allowed. You can perfectly do
property EnumStringArray: TTestObjectEnumerator read GetString;
For S in Mytest.EnumStringArray
Typing this extra letters is not going to hurt.
Your proposal violates the rule that the resulting type of an
expression must be known when evaluating it.
with
Mytest.StringArray
it is not clear what the Mytest.StringArray should evaluate to.
It can be 2 things:
- An array, in which case an index is needed.
- An enumerator.
From the above example "Mytest.StringArray" can only evaluate to
TTestObjectEnumerator. Nothing else.
Well, this is IMHO not correct. The array is also a possibility.
The compiler encounters Mytest.StringArray - at that point he has 2
possibilities. It's an array (and an index must expected) or it is an
enumerator (and nothing must be expected), but at this point the compiler
cannot decide without looking at the context.
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel