title: Delphi Copy-on-Write for String
body: <p>I have a code like this:</p>
  
  <pre><code>function Test: string;
  var
     r, s: string;
  begin
     r := 'Hello';
     Writeln(NativeInt(PChar(@r[1])));
     s := r;
     Writeln(NativeInt(PChar(@s[1])));
     Result := r;
     Writeln(NativeInt(PChar(@Result[1])));
  end;
  </code></pre>
  
  <p>People say that delphi uses copy-on-write for strings. but the above function prints 3 different Addresses for variable, r, s, and Result. So this is confusing.. Is there only a copy of 'Hello' string in memory?</p>