On Sat, Jan 9, 2021 at 8:14 PM Yuriy Sydorov via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
> > So, I'll use a for loop to copy the data. > > > > I assume that doing Arr[Index] := Default(T) will also finalize the > > element if that element ismanaged? > > For class object instances call Arr[Index].Free, for other managed types or > records containing managed types > Finalize(Arr[Index]) should work. In the base class, is there a way to check wether Arr[Index] is an object instance or a managed type or a datatype containing a managed type? Now the for loop (I abandoned the use of Move) does something like this: Arr[NewIndex] := Arr[OldIndex]; //do I have to finalize/free Arr[NewIndex] also in this case? Arr[OldIndex] := Default(T); //I understand this is not enough in those cases I could of course add an (empty) method FinalizeOrFreeElement(Elem: T); to the base class and call that inside the loop, but that feels a bit sloppy. -- Bart _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal