On 14.04.2012 11:39, Jürgen Hestermann wrote:
Sven Barth schrieb:
>> String is generic so it can be pchar, shortstring or ansistring or ....
> Please note that String can NEVER be PChar (though there is
assignment compatibility between the two to some extent). The possible
types for String are ShortString, AnsiString and maybe in the future
(and in Delphi 2009+) UnicodeString.
So what? Can it NEVER be PChar or just SOMETIMES?
A small test program
----------------
procedure XTest(X : String);
begin
X := 'AA';
end;
var S : String;
P : pchar;
begin
P := 'TEST';
S := P;
XTest(P);
end.
----------------
compiles without errors
There is a difference between "String" being a "PChar" and having
internal type conversions between "String" and "PChar". The former is
never the case while the second one is true.
"String" is defined as either being "AnsiString", "ShortString" or
"UnicodeString" depending on the used compiler and settings.
Then again "PChar" is assignment compatible to "AnsiString",
"ShortString" and "UnicodeString" and thus also to "String", as "String"
is one of those three types. This does not mean though that "String" is
a "PChar".
Regards,
Sven
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus