Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal schrieb am Mo., 18. März 2024, 13:30: > > > > On Mar 18, 2024, at 5:29 PM, Michael Van Canneyt via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > Of course there must be, that's the whole point of copy-on-write. > > > > As soon as one reference is chang

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Tomas Hajny via fpc-pascal
On 2024-03-18 13:29, Hairy Pixels via fpc-pascal wrote: On Mar 18, 2024, at 5:29 PM, Michael Van Canneyt via fpc-pascal wrote: Of course there must be, that's the whole point of copy-on-write. As soon as one reference is changed, a copy is made if the reference count is larget than 1, and t

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Hairy Pixels via fpc-pascal
> On Mar 18, 2024, at 5:29 PM, Michael Van Canneyt via fpc-pascal > wrote: > > Of course there must be, that's the whole point of copy-on-write. > > As soon as one reference is changed, a copy is made if the reference count > is larget than 1, and this copy is changed. Oh, it does copy on wr

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Michael Van Canneyt via fpc-pascal
On Mon, 18 Mar 2024, Hairy Pixels via fpc-pascal wrote: On Mar 18, 2024, at 3:27 PM, Hairy Pixels wrote: Oh, it's a pointer to a pointer? I guess that explains how it can resize itself and not invalidate shared references, if those are even possible with AnsiString. Wait, that's total

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Marco van de Voort via fpc-pascal
Op 18-3-2024 om 09:27 schreef Hairy Pixels via fpc-pascal: do that, you'll have the same output 3 times. Oh, it's a pointer to a pointer? No, it is a pointer variable, but you take the address (@) of that pointer, which causes the second indirection _

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Hairy Pixels via fpc-pascal
> On Mar 18, 2024, at 3:27 PM, Hairy Pixels wrote: > > Oh, it's a pointer to a pointer? I guess that explains how it can resize > itself and not invalidate shared references, if those are even possible with > AnsiString. Wait, that's totally wrong. :) @s is the address of the local variable

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Hairy Pixels via fpc-pascal
> On Mar 18, 2024, at 1:52 PM, Michael Van Canneyt via fpc-pascal > wrote: > > An ansistring is a pointer to a memory block. > > You are printing the address of S1 and the address of S, i.e. the address of > the pointer itself, not the address of what S (or s1) points to. Obviously > the add