[fpc-devel] New feature discussion: for-in loop

Paul Ishenin webpirat at mail.ru
Wed Oct 21 16:35:54 CEST 2009


Michael Van Canneyt wrote:
> My only worry now is to make sure that if they are implemented, that 
> we make the design as clean as possible: e.g. No hardcoded 
> dependencies on class or
> interface names.
We need to count the pros and contras first regards hardcoded names and 
maybe 'hard coded' code. For example for me  the hardcoded 'Result' 
identifier for all functions is a big advantage. But you are still using 
the function names to set the result values I suppose. So during this 
clean design designing we need to find a compromise between 2 approaches.

for example, would you argue if iterator will be any container type: 
object/class with the next declaration:

TMyIterator = object
public
  function StepNext: Boolean;
  property TheCurrentValue: Integer;

  iterator MoveNext = StepNext;
  iterator Current = TheCurrentValue;
end;

When 'iterator MoveNext' or 'iterator Current' are not defined then 
compiler uses default hardcoded identifiers 'MoveNext' and 'Current'.

This is very like to how you can bind interface methods to the class 
methods if they are differ.

Best regards,
Paul Ishenin.



More information about the fpc-devel mailing list