On Sun, Nov 14, 2010 at 08:52, Graeme Geldenhuys <graemeg.li...@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 _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel