Am 2014-02-09 17:47, schrieb Sven Barth:
On 09.02.2014 16:34, Flávio Etrusco wrote:

In other words: dynamic arrays are like AnsiStrings without the
copy-on-write semantics. I'd certainly wish Borland copied the COW
semantics :-/

Dynamic arrays have full COW semantics.

Now I am fully confused.
It's hard to find out how things work in Free Pascal given the poor 
documentation.
This sentence from http://www.freepascal.org/docs-html/ref/refsu18.html is 
*very* misleading:

"Dynamic arrays are reference counted: assignment of one dynamic array-type variable 
to another will let both variables point to the same array. Contrary to ansistrings, an 
assignment to an element of one array will be reflected in the other: there is no 
copy-on-write."

Reference counted? Point to the same array? No copy-on-write?
It seems you cannot believe anything from the documentation.
You must question every statement.
*Everything* can only be determined by writing test programs.
I now found a similar posting 5 years ago regarding the same issue:

http://lists.freepascal.org/lists/fpc-pascal/2009-February/020198.html

Why ist this not part of the documentation?
So it seems there is a copy-on-write *but* only when using SetLength.
What a very consistent design!

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

Reply via email to