[Lazarus] String vs WideString
Tony Whyman
tony.whyman at mccallumwhyman.com
Tue Aug 15 10:34:57 CEST 2017
On 14/08/17 17:47, Sven Barth via Lazarus wrote:
> The main problem of such a dynamic type would be the inability to do
> fast indexing as the compiler would need to insert runtime checks for
> the size of a character. I had already thought the same, but then had
> to discard the idea due to this.
Is this really a big problem? It is not as if it would be necessary to
do a table lookup everytime you index a string as the indexing method
could be an attribute of the string and updated with the character
encoding attribute. Is it really that complicated for the compiler to
generate code that jumps to an indexing method depending upon a data
attribute?
Is your problem really more about the result type as, depending on the
character width, the result could be an AnsiChar or WideChar or a UTF8
character for which I don't believe there is a defined char type (other
than an arguable mis-use of UCS4Char)?
I can accept that a clear up of this area would also have to extend to
the char types as well - but I would also argue that that is well
overdue. On a quick count, I found 7 different char types in the system
unit.
More information about the Lazarus
mailing list