On 02.11.2015 16:12, Ondrej Pokorny wrote:
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's not a general compiler bug, but only in relationship with helpers (I can't trigger it if I have a class constructed that way without a helper). Nevertheless it's a bug and it should be fixed. As I have written the bug report: would you please report it as a separate bug?

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?

I personally prefer the "enumerator" approach. You'll hear from me in a moment regarding your patch (I was a bit busy at the weekend otherwise I would have answered earlier).

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to