[fpc-pascal] code example where AnsiString used in FCL (SqlDB) causes data loss

Santiago A. svaa at ciberpiula.net
Wed May 11 19:35:34 CEST 2016


El 11/05/2016 a las 16:38, Michael Van Canneyt escribió:
>
>> FPC 3.0 adds unsafe auto-conversions
>
> Why do you think it is unsafe ?
>
I have an answer for this.

In short:
Different codepage strings and raw strings should be considered
different incompatible types. Pascal is a hardtyped language, and I love
that, and codepages are prone to errors (all these threads prove it).

Something about codpages needs a second thought.

a) There shouldn't be automatic conversion at all.
b) The codepage of a string shouldn't change when you assign a string
with another codepage, just rise an error.
c) Corollary of previous premises: Empty strings should also have codepage.

Extra 1) Beside calling SetSetcodepage, it would be handy that you could
set the codepage when you declare a string. I don't mean codepage should
be statically typed, just it would be handy.
Extra 2)  Being able to set the codepage statically, so that mismatch
codepage could be detected in compiler time, would be handy. In this
case I do mean codepage could also be statically typed,

-- 
Saludos

Santi
svaa at ciberpiula.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160511/df668bad/attachment.html>


More information about the fpc-pascal mailing list