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

Paul Ishenin webpirat at mail.ru
Tue Oct 20 15:02:08 CEST 2009


Martin wrote:
> "using" seems far better than a "fixed name GetIterator procedure".
>
> IMHO the other option is to implement the feature for ase types (e.g. 
> enum, array, maybe string) and allow operator overriding for all other 
> types.
>
> Then you can specify an enum operator for classes, or even for 
> simple/scalar types like integer, and define your for..in behaviour 
> for them.
Yes, 'using' and 'operator GetEnumerator' are suggested in the wiki page 
here: http://wiki.lazarus.freepascal.org/for-in_loop#Proposed_extensions
So at least here we are thinking the same :)

The big problem question is "what is enumerator" :

a) A new type very like to a specially defined object. If so then will 
we allow it usage outside for-in loop?
b) A class with one magic method and one magic property
c) something else

Best regards,
Paul Ishenin.



More information about the fpc-devel mailing list