[fpc-devel] Debug compiler
Ondrej Pokorny
lazarus at kluug.net
Sun Nov 1 21:03:15 CET 2015
On 01.11.2015 16:38, Jonas Maebe wrote:
> 1) do you a) forbid an enumerator specification if the class already
> has an enumerator
No, it's not needed.
> b) hide the existing enumerator
No, it's not needed.
> or c) allow enumerating both via the property and the original class
> enumerator?
There can never be a situation where property and class enumerators
compete. property enumerator is by design allowed only for array properties:
*property A[index: xyz]*. They cannot introduce an enumerator with
current trunk.
> If you all both, how do you differentiate? If b), first assigning the
> property to a variable
You cannot assign an array property to a variable. It does not exist
without the index parameter.
> and iterating over that will have a different result than directly
> iterating over the property, which is bad for understandability and
> code predictability.
This can never happen. Array property does not exist without the index
parameter.
---
You probably missed the fact that property enumerator can be introduced
only for array properties. I talk about it in the issue report
http://bugs.freepascal.org/view.php?id=28820 :
/
Please note that the "enumerator" keyword can be used only for "array"
properties because normal properties can have a default enumerator defined./
Also the patch I uploaded is written in regard to this design. See in
project1.lpr (uncomment the enumerator keyword for testing):
* property MyString: string read GetMyString;// enumerator
GetEnumerator2; // <-- try to uncomment, this has to fail to compile
(correct) !**
*
Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20151101/c86ebd8f/attachment.html>
More information about the fpc-devel
mailing list