Category : Modula II Source Code
Archive   : FASTR.ZIP
Filename : README.STR

 
Output of file : README.STR contained in archive : FASTR.ZIP
(*====================================================================*)
(* Peter M. Perchansky *)
(* 412-1 Springside, Drive East *)
(* Shillington, PA 19607 *)
(* *)
(* FidoNet 1:273/101 *)
(* Interlink *)
(*====================================================================*)

The following library module, FASTR, was found in the March/April 1990
Issue (Vol. 9, No. 2) of the Journal of Pascal, Ada, and Modula-2.

The implementation was written by David E. Boddy; and was written for
use with TopSpeed Modula-2.

Here are some portions of "Fast Strings for Modula-2:"

Recently there has been discussion concerning the unfortunate
method for representing variable-length string in C, Modula-2, and
other languages. This method employs the use of a special
character, usually the Null-Character (CHR (0)) as a trailer to
delmit the length of a string strored in an array of characters.
The major disadvantage of this method seems to be that a complete
scan of the string is needed to determine its length. since this
operation is performed as a part of the majority of useful string
operations, the cost of computing the length is indeed significant.

In PL/I, Turbo Pascal, and other languages, the convention for
representing variable-length strings within an array of characters
is to employ a length descriptor-byte as the invisible zeroth
character in the array. While this method is fast, it limits the
length of strings to 255 and is not compatible with the conventions
of Modula-2 and C (ie. no delimiting character is used).

Born and Dijkstra introduced a method of representing strings that
is compatible with the conventions of C, Modula-2, etc., and also
allows for representing the lenght of the string within the array.
It usually marks the end of the string with the Null-Character, it
permits strings to be as long as 64K, and yet requires no scanning
to find the length of the string. This method represents strings
in a way that is otherwise compatible and yet greatly reduces the
time needed to determine the length of a string.

For this method three cases may be identified, based on the
difference between the length of the array container and the length
of the string stored in the container:

1. The difference is zero. In this case the string fills the
array and no delimiter is used. (in the other two cases,
the string is null-delimited.)
2. The difference is at most N. In this case, the last
character in the array stores this difference, diminished
by one.
3. The difference exceeds N. In this case, the last
character in the array is set to CHR(255) to mark the case,
and the actual length of the string is stored in the two
bytes immediately preceeding the last character of the
array.

The value used for N is 255, which is the largest possible value
under this representation.

The above-represented strings are null-delimited and hence
compatible with all other Modula-2 systems that deal with strings.
However, not all strings created by a Modula-2 program are
compatible with the above. For example, any string read using the
standard procedure IO.RdStr will be null-delimited, but will not be
represented as above. For compatibility, such strings must be
converted to the above form (see Fix in definition module).

Please feel free to contact me via postal mail, FidoNet, or Interlink
(language or Pascal Conference Conference>) if you have any questions or comments.


  3 Responses to “Category : Modula II Source Code
Archive   : FASTR.ZIP
Filename : README.STR

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/