[fpc-pascal] for..in loops?

Marco van de Voort marcov at stack.nl
Sun Nov 20 10:57:32 CET 2005

> I was also wondering HOW it would be done, but I just assumed that
> everything was easy for you guys :)
> Would it be hard for the compiler to try to automatically convert
> this new construct into an equivalent older one? .. So when it finds 
> for S in ArrayOfInteger do ...
> it silently converts it to 
> for i := 0 to {Count} do
>   begin
>     S := ArrayOfInteger[i];
>     ...
> ?  I don't know enough about the internals to know how hard it is to
> know the limits of the array and the type...

It would require special tailored code for each type. (normal arrays, open
arrays, dynarrays, pchars (length) etc etc) Moreover, what's the point?
> I'd have to agree though, that this isn't a big deal one way or the
> other.  One note:  The D2006 marketing materials (AFAICT) suggest
> that this isn't just a .NET thing.

Nobody uses it unless they are backporting from .NET. Simply because the
hordes of win32 Delphi programmers still use D6 and D7.

More information about the fpc-pascal mailing list