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

Paul Ishenin webpirat at mail.ru
Sun Oct 25 12:57:28 CET 2009


Alexander Klenin wrote:
> AFAIU, the whole point of the previous discussion is
> that you do not have to implement "GetIterator" separately
> from "GetEnumerator" -- you can have the same class filling both roles.
>   
Yes. I think we can use some common interfaces/classes/objects in RTL 
both for the for-in loop enumerators and as iterators with all that 
methods which Graeme implemented.

I already created delphi compatible enumerator classes for the basic RTL 
lists: TFpList, TList, TStrings, TComponent and TCollection. We can 
inherit all them from the TInterfacedObject and Graeme interfaces. And 
list classes will have 2 methods: GetEnumerator: TSomeEnumerator and 
GetIterator: ISomeIterator where TSomeEnumerator implements 
ISomeIterator interface.

Graeme, what do you think?

Best regards,
Paul Ishenin.



More information about the fpc-devel mailing list