1.2.2 Data types

The object holds information in variables. As the name hints these
are labeled containers that may hold information that varies from time
to time. It processes information in functions that both use and
return data of various kinds.

In principle only one kind of data type is needed, a sort of general
container that would cover anything you wanted to do. In reality it's
much preferred if you can distinguish between different types of information.
This might seem only to add to your programming problems, but in fact it
reduces the risk of faulty code and improves legibility. It much
improves on the time it takes to code and debug an object.

In LPC it is possible to use only that 'general purpose' data type I was
talking about before. In the first versions of the language it was the only
kind available. However, with the LPC we have today it is much preferable
if you avoid that as much as you can. In fact, start all your programs with
the following instruction on a single line:

#pragma strict_types

This is an instruction to the gamedriver to check all functions so that
they conform to the situation they are used in, and cause compile errors
otherwise. This is a very great help in detecting programming errors early
so that you don't wonder what's going on later when things don't turn out
quite the way you wanted.

Now, the following types of data types are defined:

`void'

`Nothing'

This data type is used exclusively for functions that
don't return any data at all.

Decimal numbers of any kind in the approximate range 1.17549435e-38 to
3.40282347e+38. e.g. 1.3, -348.4, 4.53e+4. The range values are
approximate since this might vary from mud to mud as it's platform
dependant.

If there are any FORTRAN fossils around there, beware that numbers like
1. or .4711 are not recognized as floats, you have
to specify both an integer and a decimal part, even if they only are 0.

`string'

`Character strings'

Strings are simply a series of printable characters within quotes,
e.g. "x", "the string", "Another long string with the number 5 in
it". Strings can contain special characters like newline ("\n")
to end a line. A lot of LPC expressions can handle strings directly,
unlike usual C. This makes strings very handy and easy to use.

`mapping'

`Associated value pair list'

Mappings are another handy LPC invention (memory expensive, use with
care!). A mapping is simply a list of associated values. Assume you want
to remember the ages of people, like Olle is 23, Peter is 54 and Anna is
15. In LPC you can write this as ([ "Olle":23, "Peter":54,
"Anna":15 ]). As you can see the value to the right has been associated
to the value to the left. You can then extract the associated value
through a simple indexing operation using the left hand value as index.

`object'

`Object pointer'

They are references to LPC programs that has been loaded into memory.

`function'

`Function pointer'

They are references to LPC functions.

`Array'

All of the above can appear in arrays, indicated by a * in front of
the variable name in the declaration.

Arrays in LPC are more like lists than proper arrays. A number of functions
and operator facilities exist to make them easy and quick to use.

`mixed'

This, finally, is a general descriptor covering all the other, a sort of
jack-of-all-trades type. Again, let me stress the fact that using it
except when absolutely necessary only provokes mistakes.

Hmm, as pointed out to me this might sound a bit too strict. The mixed
type is used for good reasons fairly often. What I mean is that when
a specific type can be used, you should use it. Don't substitute it for
mixed just because you feel lazy.