On 01.11.2015 21:03, Ondrej Pokorny wrote:
You cannot assign an array property to a variable. It does not exist without the index parameter.
OK, there is a bug in ppc that allows to use an array property with *any paramete**r(s)* (also no parameter). Delphi does not allow it.
Actually ppc doesn't check if *MyProp[Index]* matches the property declaration but if there is an (overloaded) function that matches the Index parameter. Therefore you can declare a parameterless function with property getter's name that returns the enumerator and it will be used in the for-in loop!
I still think that it is a ppc bug and it would be better to have a clean way to do that. But if you don't like to extend the compiler, please don't fix this bug either.
It was still a good practice for me to play with the compiler. I wouldn't have found the bug without studying the compiler code. You can find demo code that shows how to create an array property enumerator in the issue report: http://bugs.freepascal.org/view.php?id=28820#c87065
Sven Barth & Michael Van Canneyt: you also showed an interest. What is your opinion about it?
Ondrej
_______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
