[fpc-pascal] Dynamic arrays, yet another pitfall

Florian Klämpfl florian at freepascal.org
Sun Feb 9 19:29:01 CET 2014


Am 09.02.2014 18:41, schrieb Jürgen Hestermann:
> So it seems there is a copy-on-write *but* only when using SetLength.

No. There is no COW, only ref. counting. SetLength just forces an unique
instance of the array if needed.

> What a very consistent design!

There is a very good reason for this design: speed. COW would mean that
at every write to a dyn. array element, ref. count must be checked. This
would render dyn. arrays useless for a lot of applications due to poor
speed. So dyn. arrays with COW simply make no sense.



More information about the fpc-pascal mailing list