> On Oct 13, 2019, at 5:58 AM, Sven Barth via fpc-pascal > <fpc-pascal@lists.freepascal.org> wrote: > >> Delphi does not allow it: >> >> [dcc32 Error] Project1.dpr(18): E1019 For loop control variable must be >> simple local variable >> >> I don't think this should be allowed, either. > > Same.
Why not? I just had this problem on 9/26, search for “for-in loop cast”. What if I have a list of TObjects I want to iterate? I know TMyClass is safe to use but the compiler complains so I override it with a typecast. If you take that away I’ll have to do tons of casting outside of the loop. var arr: specialize TFPGObjectList<TObject>; obj: TMyClass; begin arr := specialize TFPGObjectList<TObject>.Create; arr.Add(TObject.Create); // Incompatible types: got "TObject" expected "TMyClass" for obj in arr do begin end; Regards, Ryan Joseph _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal