> On Oct 14, 2019, at 8:02 AM, Sven Barth via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> No. Nothing of that. There is a variable in the for-in-loop and nothing more. 
> Anything else currently is a bug and *will* break. 
> 

I don’t disagree with anything you’re saying but this is going to make for-in 
loops much harder to work with. Pascal isn’t like C++, C#, Python etc… where 
there are “auto” vars we can use for the iterator. Since I don’t want to 
typecast every single time I access the iterator I’m probably going to make a 
temporary iterator and then assign it to the real variable inside the loop.

var
  it: pointer;
  obj: TObject;
begin
  for it in list do
    begin
      obj := TObject(it);
      // continue on like before using “obj” instead of “it"
    end;


That’s our realistic best use case now but it requires 2 extra steps. I hope 
there’s a better solution to keep the for-in loops as easy to use as before.


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to