Răsfoiți Sursa

- ansistring memory record moved to programmer's reference
* some small syntax errors

carl 24 ani în urmă
părinte
comite
611bff7511
1 a modificat fișierele cu 15 adăugiri și 34 ștergeri
  1. 15 34
      docs/ref.tex

+ 15 - 34
docs/ref.tex

@@ -750,8 +750,9 @@ When the single quote character must be represented, it should be typed
 two times successively, thus \var{''''} represents the single quote character.
 
 \subsection{Strings}
-\fpc supports the \var{String} type as it is defined in Turbo Pascal and
-it supports ansistrings as in Delphi.
+\fpc supports the \var{String} type as it is defined in Turbo Pascal
+(A sequence of characters with a specified length) and it
+supports ansistrings as in Delphi.
 To declare a variable as a string, use the following type specification:
 \input{syntax/sstring.syn}
 
@@ -761,7 +762,7 @@ ansistrng or a short string.
 
 Whatever the actual type, ansistrings and short strings can be used
 interchangeably. The compiler always takes care of the necessary type
-coversions. Note, however, that the result of an expression that contains
+conversions. Note, however, that the result of an expression that contains
 ansistrings and short strings will always be an ansistring.
 
 \subsection{Short strings}
@@ -780,11 +781,9 @@ The predefined type \var{ShortString} is defined as a string of length 255:
  ShortString = String[255];
 \end{verbatim}
 
-For short strings \fpc reserves \var{Size+1} bytes for the string \var{S},
-and in the zeroeth element of the string (\var{S[0]}) it will store the
-length of the variable.
 If the size of the string is not specified, \var{255} is taken as a
-default.
+default. The length of the string can be obtained with the \seef{Length}
+standard runtime routine.
 For example in
 \begin{verbatim}
 {$H-}
@@ -793,9 +792,8 @@ Type
    NameString = String[10];
    StreetString = String;
 \end{verbatim}
-\var{NameString} can contain maximum 10 characters. While
-\var{StreetString} can contain 255 characters. The sizes of these variables
-are, respectively, 11 and 256 bytes.
+\var{NameString} can contain a maximum of 10 characters. While
+\var{StreetString} can contain up to 255 characters.
 
 \subsection{Ansistrings}
 
@@ -807,23 +805,12 @@ counted. Internally, an ansistring is treated as a pointer.
 
 If the string is empty (\var{''}), then the pointer is nil.
 If the string is not empty, then the pointer points to a structure in
-heap memory that looks as in \seet{ansistrings}.
-
-\begin{FPCltable}{rl}{AnsiString memory structure}{ansistrings}
-Offset & Contains \\ \hline
--12  & Longint with maximum string size. \\
--8   & Longint with actual string size.\\
--4   & Longint with reference count.\\
-0    & Actual string, null-terminated. \\ \hline
-\end{FPCltable}
-
-Because of this structure, it is possible to typecast an ansistring to a
-pchar. If the string is empty (so the pointer is nil) then the compiler
-makes sure that the typecasted pchar will point to a null byte.
+heap memory.
 
-AnsiStrings can be unlimited in length. Since the length is stored,
-the length of an ansistring is available immediatly, providing for fast
-access.
+It is possible to typecast an ansistring to a pchar.
+If the string is empty (so the pointer is nil) then the compiler
+makes sure that the typecasted pchar will point to a null byte. AnsiStrings
+can be unlimited in length.
 
 Assigning one ansistring to another doesn't involve moving the actual
 string. A statement
@@ -866,14 +853,8 @@ statements:
 then a copy of the string is created before the assignment. This is known
 as {\em copy-on-write} semantics.
 
-It is impossible to access the length of an ansistring by referring to
-the zeroeth character. The following statement will generate a compiler
-error if S is an ansistring:
-\begin{verbatim}
-  Len:=S[0];
-\end{verbatim}
-Instead, the \seef{Length} function must be used to get the length of a
-string.
+The \seef{Length} function must be used to get the length of an
+ansistring.
 
 To set the length of an ansistring, the \seep{SetLength} function must be used.
 Constant ansistrings have a reference count of -1 and are treated specially.