I would also add that it's wise to employ overloaded commands for each data structure that contains dynamic arrays. There may be nested dynamic arrays, and Delphi at least would not respect copying over nested data structures that contained Dynamic Arrays, so I write Copy, Empty, SetSize routines for all my data types that contain dynamic arrays.
I would like to point out that it would be nice if we could have lamda expressions. Does FPC already have this or is it planned? On Mon, Dec 22, 2008 at 9:38 AM, Florian Klaempfl <flor...@freepascal.org> wrote: > Jonas Maebe schrieb: >> >> One important different to keep in mind between dynamic arrays and regular >> arrays (including those defined using schema types): dynamic arrays are >> reference counted and copies are always shallow copies. This means that in >> this code: >> >> var >> a, b: array of real; >> begin >> setlength(a,10); >> b:=a; > > The proper way to do a copy is > b:=copy(a); > :) > > It's only a one level deep copy though. > > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal