Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Lukasz Sokol
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 :

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Michael Van Canneyt
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

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Jürgen Hestermann
Am 2014-02-17 10:38, schrieb Lukasz Sokol: To 'write' usually means : changing DATA element(s). That's it. What else is it when adding or removing elements? The array is modified. That can only mean it was written to it. SetLength is /not/ a write in this sense : because you're resizing the

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Martin Frb
On 17/02/2014 16:40, Jürgen Hestermann wrote: Am 2014-02-17 10:38, schrieb Lukasz Sokol: To 'write' usually means : changing DATA element(s). That's it. What else is it when adding or removing elements? The array is modified. That can only mean it was written to it. SetLength is /not/ a

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Martin Frb
On 17/02/2014 16:40, Jürgen Hestermann wrote: But changing the size it is a modification! When an array can be resized then the resizing means that I have to write to it (in contrast to reading, where no data is modified). I am astonished that everybody here seems not to see this. Maybe

Re: [fpc-pascal] SVN revisions and builds

2014-02-17 Thread Reinier Olislagers
On 04/02/2014 13:45, Sven Barth wrote: Am 04.02.2014 11:35, schrieb Constantine Yannakopoulos: I tried to compile FPC from source using FPCUP with its default options using the latest trunk code but it failed to compile LCL, probably due to Unicode changes. Could you tell me what is the most

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Jürgen Hestermann
Am 2014-02-17 18:01, schrieb Martin Frb: On 17/02/2014 16:40, Jürgen Hestermann wrote: It appears, that the copy-on-setlength is intended. So in that the documentation is right. It is intended but is was not mentioned in the documentation. Therefore this whole thread exists at all. As for

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Martin Frb
On 17/02/2014 17:28, Jürgen Hestermann wrote: Am 2014-02-17 18:01, schrieb Martin Frb: On 17/02/2014 16:40, Jürgen Hestermann wrote: It appears, that the copy-on-setlength is intended. So in that the documentation is right. It is intended but is was not mentioned in the documentation.

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Jürgen Hestermann
Am 2014-02-17 18:49, schrieb Martin Frb: Then why does this discussion continue, now that it is documented? Does it matter what other people consider a write and what not? (Unless that part made it into the docs, but there was no mention it did)? Of course it would not matter if it wasn't

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Jonas Maebe
On 17 Feb 2014, at 19:19, Jürgen Hestermann wrote: And I have not seen what change was made to the documentation. svn co http://svn.freepascal.org/svn/fpcdocs/trunk It's the same as when something is fixed in FPC: this does not change anything to the latest release, which is what's available

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Martin Frb
On 17/02/2014 18:19, Jürgen Hestermann wrote: Am 2014-02-17 18:49, schrieb Martin Frb: Then why does this discussion continue, now that it is documented? Does it matter what other people consider a write and what not? (Unless that part made it into the docs, but there was no mention it did)?

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Marco van de Voort
In our previous episode, Martin Frb said: Just because there is a function, that includes copying (when modifying the array), does not mean there is copy on write. So basically, if for a given size x, setlength(x,1) always reallocates, then it is COW, otherwise not :-) (and even if it does,

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Martin Frb
On 17/02/2014 19:34, Marco van de Voort wrote: In our previous episode, Martin Frb said: Just because there is a function, that includes copying (when modifying the array), does not mean there is copy on write. So basically, if for a given size x, setlength(x,1) always reallocates, then it is

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Jonas Maebe
On 17 Feb 2014, at 20:41, Martin Frb wrote: Dynamic arrays have no copy-on-write. But SetLength perform a copy-on-write on dynamic arrays. I am not sure, if that makes to much sense either It doesn't, because even if you don't change the length it makes a unique copy. Jonas

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Martin Frb
On 17/02/2014 19:50, Jonas Maebe wrote: On 17 Feb 2014, at 20:41, Martin Frb wrote: Dynamic arrays have no copy-on-write. But SetLength perform a copy-on-write on dynamic arrays. I am not sure, if that makes to much sense either It doesn't, because even if you don't change the length it

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Florian Klämpfl
Am 16.02.2014 14:07, schrieb Jürgen Hestermann: When using unknown features of a programming language for the first time then the documentaion should tell all aspects in detail and describe the exact behaviour. No. Details might be implementation specific behaviour which might change.

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Florian Klämpfl
Am 16.02.2014 17:16, schrieb Michael Van Canneyt: 2) SetLength enforces unique ref. count. I'am against stating this in the docs. It is an implementation detail. The proper way to do a deep copy is using copy. ___ fpc-pascal maillist -

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Martin Frb
On 17/02/2014 20:10, Florian Klämpfl wrote: Am 16.02.2014 17:16, schrieb Michael Van Canneyt: 2) SetLength enforces unique ref. count. I'am against stating this in the docs. It is an implementation detail. The proper way to do a deep copy is using copy. IMHO, it must be documented, even if

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-17 Thread Marco van de Voort
In our previous episode, Martin Frb said: the array), does not mean there is copy on write. So basically, if for a given size x, setlength(x,1) always reallocates, then it is COW, otherwise not :-) That came out wrong wrong. Should've been for given x, setlength(p,x+1); p (after) is