On Sun, 16 Feb 2014, Jürgen Hestermann wrote:


Am 2014-02-15 19:41, schrieb Michael Van Canneyt:
That setlength behaves rather freakish for dynamic arrays, does not mean we have copy-on-write.

Well, setlength *is* a write.
What else is it?
Doesn't it write to the array?

Depends on how you define 'write to the array'.

"Writing to the array" = "Changing the value of one of the elements in the 
array."

In this sense, setlength does not write to the array, which would mean changing 
the value of
one or more of the elements in the array. It does not do that. It resizes the 
array and
the result is by definition a different array.

But taking the above definition, with "element" = "character", you see that ansistrings do have copy-on-write.

It's largely a question of semantics, I suppose.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to