Re: [fpc-pascal] Managed types within records
Am 28.05.2015 18:16 schrieb Jürgen Hestermann juergen.hesterm...@gmx.de: Hi, when I have a record which has managed types (i.e. strings), how are they handled by the compiler when I assign one record to the other? Example: --- type MyRecordType = record X : SizeInt; S : AnsiString; end; var A,B : ^MyRecordType; begin new(A); new(B); A^.X := 7; A^.S := 'String in A'; B^ := A^; Dispose(A); end; --- What happens to the reference counter of S? Is it updated correctly (assigned to zero with new, incremented with B^:=A^ and decremented with dispose)? Yes, they are handled correctly. The compiler inserts a call to a RTL function that does a per-element copy using the record's RTTI instead of doing a memory copy (this is true for all records even if they don't have managed types). Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I write a multithread program as simple as possible?
On 05/28/2015 12:30 AM, Sven Barth wrote: Where did you get the idea that we already have that? Someone /is/ working on it (or is even finished), but nothing is in trunk yet. We discussed this in the fpc-devel List and I learned that Delphi has the anonymous syntax since D2009. It was mentioned in several discussions. So I had the - seemingly wrong - impression that it already is available. -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Managed types within records
Hi, when I have a record which has managed types (i.e. strings), how are they handled by the compiler when I assign one record to the other? Example: --- type MyRecordType = record X : SizeInt; S : AnsiString; end; var A,B : ^MyRecordType; begin new(A); new(B); A^.X := 7; A^.S := 'String in A'; B^ := A^; Dispose(A); end; --- What happens to the reference counter of S? Is it updated correctly (assigned to zero with new, incremented with B^:=A^ and decremented with dispose)? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal