[fpc-devel] static vs dynamic arrays

Michael Van Canneyt michael at freepascal.org
Tue Apr 4 16:17:54 CEST 2006



On Tue, 4 Apr 2006, ???? ??????????? wrote:

>> Because of the copy-on-write mechanism. The reference count must be
>> checked each time you do a write. This is normal. It's the same in
>> Delphi, and a good reason for avoiding dynamic arrays.
>>
>> You can use pointer arithmetics in FPC, it works as a dynamic array, but
>> without the overhead.
>
> This topic (when trying to read it from the beginning to this point) is informative about its subject, but very confusing.
>
> I have already been confused with blockread() and dynamic arrays. (It's about "formal const" parameter and ability to pass one kind of array as parameter and inability to pass the other.)
>
> Also I constantly fear array assignments.
>
> Probably I will use something similar to your example ("manual" dynamic array?).
>
> Could anyone state the reason of the way dynamic arrays are implemented?

Delphi compatibility. It's a Delphi construct.

> Can I "disable" reference counting for some types or something?

No.

Ansistrings, WideStrings and Dynamic arrays are always reference counted.

Michael.



More information about the fpc-devel mailing list