On Tue, 20 Oct 2009, Graeme Geldenhuys wrote:

2009/10/20 Paul Ishenin <i...@kmiac.ru>:

It is obvious you are full of energy to discuss new language features.

:-)


The next feature which we should think of is for-in loop:
http://wiki.lazarus.freepascal.org/for-in_loop

As an alternative to the very limited "for-in", I have a better and
more flexible design, using the Iterator design pattern. I have
already written iterations for most of FPC's list components. It would
be nice if the iterators could be part of the default list component
and not as an external unit like I currently have.  I'm willing to do
the work in merging my external iterators with the various list
components. Just say the word.

It allows you to write code as follows, irrespective of what list
component you are working with.

 MyIterator := MyList.GetIterator;
 while MyIterator.HasNext do
   ShowMessage(MyIterator.Next);


The iterator interfaces has a lot more functions that just .HasNext and .Next.

Exactly.

I think that Graeme's approach is much better than the very unpascal-ish for Y in Someclass do
and would much prefer this to be implemented in the RTL.

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to