[fpc-devel] for-in-index loop

Sven Barth pascaldragon at googlemail.com
Fri Jan 25 20:11:36 CET 2013


On 25.01.2013 19:59, Michael Van Canneyt wrote:
>
>
> On Sat, 26 Jan 2013, Alexander Klenin wrote:
>>>>> Pascal needs more useful libraries.
>>>> It is important to note that default libraries ARE part of the language
>>> You are wrong there.
>> Well, this is a matter of opinion of course, but note that your
>> opinion on this topic is again different from the usual one:
>
> If I cared about 'usual opinion', I would be using C#.
>

Or Java ^^

>>> The student will have to remember 4 different syntaxes.
>>>
>>> For a:=b to c do
>>> for a:=b downto c do
>>> for a in b do
>>> for a in b index c do
>>>
>>> Concise ? I don't think so.
>>
>> Compared to the 10 methods of iterating over container just in the
>> current
>> FPC+Lazarus code? Yes, I think this *is* concise and clear.
>
> There is only 1 method:
>
> for i:=0 to I.Count-1.

I think he also means things like (without critizing):

MyDataSet.First;
while not MyDataset.Eof do begin
   // ...
   MyDataSet.Next;
end;
// on a sidenote: what about a TDataSet enumerator? :)

for i := 0 to MyWinControl.ChildCount - 1 do
   // ...

for i := 0 to MyWinControl.ControlCount - 1 do
   // ...

There might be more, but I don't remember them currently... :(

Regards,
Sven



More information about the fpc-devel mailing list