On 17/02/2014 16:40, Jürgen Hestermann wrote:
Am 2014-02-17 10:38, schrieb Lukasz Sokol:
> To 'write' usually means : changing DATA element(s). That's it.

What else is it when adding or removing elements? The array is modified. That can only mean it was written to it.


> SetLength is /not/ a write in this sense : because you're resizing the paper you're
> going to write on (e.g. adding another page or cutting it to size)

But changing the size it is a modification!

It does not matter.

Who says that it is an effect of the (implicit) write that triggers the copy? For strings there is UniqueInstance(), and even though it does not write to the string, it makes a copy, if needed.

SetLength is a function too.
SetLength includes making the array unique as part of its function description.

So this "making unique" does not happen because of COW (which does not apply), but because of the (now) documented effects of a function used on the array.

In the same way I can write functions for an object that performs a (modifying) operation on the object, and copies the object before.
Yet if I  wrote such code, no one would say, that the object I use, has COW.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to