by mikewarot · 2mo ago · 0 comments
According to google:
When you assign one dynamic string to another, Free Pascal does not duplicate the actual characters in memory. Instead, both variables point to the same character buffer in the heap, and the runtime increments an internal reference counter. A physical memory copy is only triggered when one of the string instances is modified (written to)
Free Pascal strings are as close as you get to magic, compared to C/C++.
String -> immutable string
StringBuilder -> mutable string, optimized methods for string modification > Free Pascal strings are as close as you get to magic, compared to C/C++.
Not your point of reference, but Java and C# treat strings as immutable objects too.Actually all dynamic array are.