[fpc-pascal] Dynamic arrays, yet another pitfall

Lukasz Sokol el.es.cr at gmail.com
Mon Feb 17 11:19:15 CET 2014


On 17/02/14 09:51, Michael Van Canneyt wrote:
> 
> 
> On Mon, 17 Feb 2014, Lukasz Sokol wrote:
> 
>> On 17/02/14 06:02, Jürgen Hestermann wrote:
>>>
>>> Am 2014-02-16 17:16, schrieb Michael Van Canneyt:
>>>> It does exactly that, it says:
>>>> 1) No COW
>>>
>>> As said already: SetLength *is* a write!
>>>
>>>
>>
>> I'm not of compiler background - but I think you're confusing things here.
>>
>> To 'write' usually means : changing DATA element(s). That's it. You have a sheet of paper of
>> known size and you write on it/erase/change the text. But the size of the array remains the same.
>>
>> 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)
>>
>> As far I understood, SetLength is changing the /description/ of the array (meta-data?) but not the data itself :
>> in this sense, it is not a 'write data' operation.
>>
>> It does 'write' as in: change parameters - of the array DESCRIPTION area, but that area is not ARRAY DATA;
>> and enlarging/shrinking the memory allocation - but that does not change the content of the already
>> written-to array elements: it may add some blank ones or remove some written-to ones, but the rest
>> remains UNCHANGED, i.e. they (the just-added or remaining-after-removal ones) are not being written-to
>> by doing SetLength.)
> 
> That is the long version of what I was trying to say. Thank you :)
> 
> Michael.
> 
> 

*grin* *wink* so many redundant words ... some need them ;)

Can you add the long(er) description to the help text ? :)

-L.




More information about the fpc-pascal mailing list