[fpc-devel] Modernising Pascal

Jamie McCracken jamie-junk at blueyonder.co.uk
Wed Feb 23 14:04:45 CET 2005


Marco van de Voort wrote:


> 
>>>>2. For Each. Its in Delphi 2005 and every modern language implements it.
>>>
>>>
>>>Yeah, and I still wonder why. There is nothing to gain with it. 
>>
>>one less variable to manually declare
> 
> 
> Implement something in lazarus that auto-adds the variable to the local var
> section. No need for language extensions.

My mistake it actually avoids initialising the loop variable rather than 
not declaring it:

for i in myarray do
   myarray[i] := 0;

as opposed to

for i := low(myarray) to high (myarray) do
    myarray[i] := 0;


I think the for..in is much clearer and more compact (it works for sets, 
arrays and other enumerated types)

jamie.

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





More information about the fpc-devel mailing list