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

Dariusz Mazur darekm at emadar.com
Wed Oct 21 21:50:38 CEST 2009


Micha Nelissen pisze:
> Michael Van Canneyt wrote:
>> I see little gain in changing
>>
>>   while Something(f) do
>>     F.Somethingelse
>
> This is not quite equal, it's more like:
>
> Start(f);
> while not Last(f) do
>   F.DoWork;
>
> In your case, the function 'Something' must know about a generic F.
why not
 f.start;
 while not f.last do
   f.doWork;
>
> There are also recursive state problems to be thought about. I guess 
> this is why in the STL an iterator is a separate object on the local 
> stack, but able to iterate through (another) object of the defined type.
Second problem is multithreading, when we try to iterate concurrent on 
the same collection.


-- 
  Darek







More information about the fpc-devel mailing list