Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-03

What's the state of "string"?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hans-Peter Diettrich

I wonder about much code in the RTL/FCL, that depends on String type arguments, like:

   Procedure TStream.WriteAnsiString (const S : String);
   Var L : Longint;
   begin
     L:=Length(S);
     WriteBuffer (L,SizeOf(L));
     WriteBuffer (Pointer(S)^,L);
   end;

This method will work only as long as String=AnsiString, because Length *bytes* are written, not *chars* of a possibly different byte count.

Is the use of generic types, like String, really okay in the library code, when the concrete type matters?

The documentation on strings (3.2 Character types) is not really helpful, most entries look like they deserve an update reflecting the role of UnicodeString and the generic String type, and implicit string conversions. In detail I miss instructions on how to determine or specify the String type, with different FPC versions.

DoDi

Reply by email

Unknown author
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 17 lines
I wonder about much code in the RTL/FCL, that depends on String type arguments, like: Procedure TStream.WriteAnsiString (const S : String); Var L : Longint; begin L:=Length(S); WriteBuffer (L,SizeOf(L)); WriteBuffer (Pointer(S)^,L); end; This method will work only as long as String=AnsiString, because Length *bytes* are written, not *chars* of a possibly different byte count. Is the use of generic types, like String, really okay in the library code, when the concrete type matters?

No. This work still needs to be done.

Show quoted text 6 lines
The documentation on strings (3.2 Character types) is not really helpful, most entries look like they deserve an update reflecting the role of UnicodeString and the generic String type, and implicit string conversions. In detail I miss instructions on how to determine or specify the String type, with different FPC versions.
{$H} is documented, {$IFOPT} is documented.

That's all there is.

As soon as the rest is implemented, it will be documented as well.

Michael.

Reply by email