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

Graeme Geldenhuys graemeg.lists at gmail.com
Sun Oct 25 09:20:27 CET 2009


2009/10/25 Paul Ishenin <webpirat at mail.ru>:
>
> I don't argue but how do you think to use HasPrevious, PeakNext,
> PeakPrevios, Reset, JumpToBack in the for-in loop? Can you suggest a syntax?

I did not expect for-in loop to support all the methods I require (or
use), hence the reason I ask, and why I still would like to extend the
list/container classes in the RTL to support those. I googled a bit
more and found that java actually supports both Iterator and
Enumerator in it's container classes. Clearly there is a use-case for
each, and one does not necessarily replace the other.

So if the for-in loop uses GetEnumerator, I can still implement the
GetIterator without conflicting with your implementation.  Looking
more at the Java class documentation, it seems Enumerator is a "lite"
version of Iterator an only supports a  small subset of Iterator
features. This same idea could be applied to the RTL, and for users
that don't want to use for-in loop syntax.


> Delphi enumerator pattern is a structure with one boolean function MoveNext
> and one property Current.  More info is here:

Thanks for the link, I'll go take a look at it shortly...


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-devel mailing list