[fpc-devel] Re: enumerators
Alexander Klenin
klenin at gmail.com
Mon Nov 15 01:55:34 CET 2010
On Sun, Nov 14, 2010 at 08:52, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
> If you use full-blown Iterator classes (instead of just for-in style)
> you get a lot more too:
>
> * full control over iteration
> - move forward
> - move back
> - reset iteration
> - peek forward/back
> - skip, etc...
> * you can extent it with regular expressions to only iterate what is
> applicable, and what
> matches the regex.
> * you completely hide the container implementation (TList,
> TObjectList, TFPList, etc)
> and simply supply the developer with a consistent iteration
> interface. So even if the
> container implementation changes, the higher level iteration code will not.
I agree that a more powerful iterator interface would be a good thing too.
However, the clarity and brevity of for..in interface should not be
underestimated.
I eagerly await a moment when Lazarus switches to FPC 2.4.2 so I could
use for..in in the Lazarus code ;-)
If your extended iterator implements enumerator interface,
you can get the best of both worlds, especially if the "index" extension
I proposed at the end of the page is implemented.
--
Alexander S. Klenin
More information about the fpc-devel
mailing list