From the reference guide, december 2008 version:
"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."
This is fine, but what is strange is that calling setlength DOES perform copy-on-write!
var a, b : array of longint;
begin
setlength (a,2);
b := a;
setlength (a,5);
writeln (length(b)); // I get 2, not 5
end.Why this inconsistency? Seems like the behaviors for assigning an element and for using setlength should be similar.
Cheers,
David
