On 01/11/15 06:26, Ondrej Pokorny wrote:
On 01.11.2015 00:11, Jonas Maebe wrote:
On 31/10/15 21:28, Ondrej Pokorny wrote:
The argument that the tenumeratornode concept is completely different
from other nodes is correct - but if you think about the syntax you will
see that also the syntax is completely different from other pascal
syntax so you need such a unique node.

That is a very good argument not to add it...

Yes, my argument that the "syntax is completely different from other
pascal syntax" is misleading. I put it wrong. It is not different - its
a new extension within the current pascal syntax:

The basic issue is that you need extra context for supporting this extension. Normally, an enumerator is searched based on the class type. In your case, it's searched either based on the class type, or if the class is returned from a property with an "enumerator" specifier, based on that enumerator declaration.

Whether you do it via a temporary node, a global variable and/or node flags, does not change that. Extra context is always bad both for the compiler implementation/maintenance and for code readability/predictability by humans.

This leads to more design design decisions:
1) do you a) forbid an enumerator specification if the class already has an enumerator, b) hide the existing enumerator, or c) allow enumerating both via the property and the original class enumerator? If you all both, how do you differentiate? If b), first assigning the property to a variable and iterating over that will have a different result than directly iterating over the property, which is bad for understandability and code predictability. If c), how do you specify it. If a), that break orthogonality (and I'm sure some people will argue that iterating over a particular property may have to be done differently than over that class' contents in the general case)

2) do you expose the "hidden/parent" enumerator of the class itself to the overriding enumerator in a property and if so, how? Maybe even iterating both at the same time via some kind of inheritance mechanism?

There are undoubtedly more.


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

Reply via email to