Graeme Geldenhuys wrote:
2009/10/20 Alexander Klenin <kle...@gmail.com>:
for-in is just a syntax sugar plus standard interface for the cost common usage
of iterators. So they are not mutually exclusive at all.

Another flaw in the for-in concept...

  What will this do:

  for y in MyList do
  begin
    if y = XXX then
      MyList.Add(YYY);
    if y = ZZZ then
      MyList.Insert(1, AAA);
  end;

With my iterator implementation I can handle this with no problems,
and ever make the resulting behaviour user-selectable with parameters
to the MyList.GetIterator method.

This is IMO similar to using a for loop vs. using a while loop. In a for loop you are not allowed to modify the loop variable. In this case I can imagine its not allowed to modify the list. If you want to, use a while and iterators. Yes I know iterators, I use them myself too on my own lists. As said I before, I think too that tose can be combined.

Marc





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

Reply via email to