F.1 String handling
Business applications use a lot of strings. Sheerpower is highly optimized
for handling strings using a number of optimization techniques.
fullname$ = 'Sally Sue'
sentence$ = fullname$ + ' was here.'
sentence$ = 'So I heard.'
Strings are handled very efficiently by Sheerpower. Each string knows both
its allocated size and its real size. For example, if a string holds the
words "The rain in Spain" and later needs to hold the shorter string of
"Enjoy life", Sheerpower can copy the characters from the new shorter string
into where the longer string was, repurposing its already allocated buffer.
Sheerpower manages all memory use for you. You never have to worry about
memory allocations or deallocations when using Sheerpower. It does this by
internally managing a series of memory pools
that it creates as the
In addition, each string is given a globally unique string ID (SID). When a
string is copied, its SID is copied to the target as well. Later, Sheerpower
avoids unnecessary string copies by first checking if the SIDs of the source
and target strings match. If they do, the copying process is avoided.
When using functions like getword$()
, Sheerpower also uses SIDs as
part of an internal hinting system
for further efficiency. For
example, if the entire contents of the Bible is stored in the variable
and you do a getword$(bible$, 1000)
and then later you
do a getword$(bible$, 1001)
, the function does not need to re-read the
first 1000 words to get to the 1001 word. It knows from the hinting system
where it last left off and returns the 1001 word immediately.
Sheerpower provides memory safety without
This eliminates the string handling slowdowns that other languages experience
Note: See the
fileinfo$() function for an easy way to read the entire contents of a file,
such as the Bible, into a variable.