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

Matt Emson memson.lists at googlemail.com
Wed Oct 21 12:00:57 CEST 2009


Micha Nelissen wrote:
> Michael Van Canneyt wrote:
>> Because with something like
>>
>> Type
>>   MyIterator = Iterator(TSomeResultType,Func1,Func2,Func3);
>
> So the place in this list determines its function?

The syntax is nice and simple, but I would have to agree. Maybe a two 
step would be better? Like with converting an enum to a set?

type
  MyIterator = Iterator of TSomeResultType;
 
  MyIteratiorDefinition = class(MyIterator) //class might be another keyword
    iteration Func1; MoveNext;
    iteration Func1; MovePrior;
    {etc}
  end;

and then tag methods as so? I think though, that the original  
suggestion would work if very well documented or allowing for additional 
tags somehow?

MyIterator = Iterator(TSomeResultType, Func1::Next, Func2::Prior);

The list could also then be variable. If it isn't variable with default 
implementations for missing members, I don't see the reason why the 
method names can't be fixed - or am I missing something obvious? Having 
a fixed list may well be confusing should it ever need to be expanded or 
adapted.

M




More information about the fpc-devel mailing list