[fpc-pascal] for..in loops?

Alan Mead cubrewer at yahoo.com
Sun Nov 20 01:15:12 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...

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.

-Alan

--- Marco van de Voort <marcov at stack.nl> wrote:

> > On Fri, 18 Nov 2005 13:18:40 -0800 (PST)
> > Alan Mead <cubrewer at yahoo.com> wrote:
> > 
> > > fpc 2.0.0 doesn't compile this... are "for..in" loops in a
> newer
> > > version or will they be sometime soon?  Here is a little blurb
> about
> > 
> > FPC will never support this, AFAIK. It doesn't really add
> anything new, it
> > just shortens the code somewhat. Only in toy examples is it nice,
> in
> > practice it doesn't really matter. We should try to keep the
> language as
> > small and clean as possible.
> 
> Note that part of this is quite elegant on .NET since basically is
> an
> object, and so everything can support some iterator interface, and
> the JIT
> can optimize a lot overhead away.
> 
> It doesn't work that way in native, and needs lots of expensive
> helpers, iow
> supporting it is a hack. Note that Perl is also OOP to a higher
> degree with
> JIT.
> 
> This is the problem with a lot of new Delphi.NET syntax. It might
> be
> backportable to native, but it feels "odd". The .NET generics have
> similar
> issues.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 




More information about the fpc-pascal mailing list