All names, values and expressions have a type. The type defines what you can do with the thing. PCC internally tracks these types. If you use a value in a way its type does not allow, PCC will show you an appropriate error message. Here are the most important data types:
- Numbers
- PCC supports fractional and whole numbers (integers). PCC internally tracks for each value whether it's fractional or integer. In general, operations between integers yield integers, whereas operations involving a fractional number yield a fractional number. Some operations require their operands to be integers, many accept either kind. For details, see Integers and Numbers.
- Boolean (Truth Values)
- Boolean values can be True or False and are used to represent yes/no answers, for example, the results of comparisons. Whenever PCC needs a boolean value, it also accepts numbers (0 means False (everything below 0.000001, actually), other values mean True) or strings (the empty string "" means False, other values mean True). Likewise, PCC also accepts booleans when it needs a number, False converts into zero, True converts into 1. For details, see Booleans.
- Strings
- Strings can contain arbitrary text, such as the name of a starship. For details, see Strings.
- Arrays and Hashes
- These contain other objects. For example, Ship is an array containing all ships. Arrays are indexed with numbers, hashes are indexed with strings. For details, see Arrays.
- Functions
- Functions compute values from other values. For example, Sqrt is a function, and Sqrt(9) computes square-root-of-9. You can also define your own functions using the Function command. For details, see Elementary Functions and Functions.
- Objects
- The result of an array reference like Ship(17) is the object, ship #17. You can access that object's properties by adding a dot followed by a property name, as in Ship(17).Name, or by using it with the With command.
For more details, see the Data Type index, which describes these types in all their variants along with cross-references.
A very special value is EMPTY. This value is used for unknown values. For example, when you don't own a ship, it will yield EMPTY for its Cargo.N (fuel amount). As a general rule, an operation will yield EMPTY if one of their operands are EMPTY, and a command will not do anything if a mandatory argument is EMPTY, but exceptions exist. In a boolean context (If), EMPTY counts as False.
Technically, subroutines and regular (=not elementary) commands are also represented as values. The only thing you can do with those, however, is invoke them in a command. You cannot use them meaningfully in expressions.
Note: Unlike PCC 1.x, PCC2 currently permits all sorts of interesting (and dangerous) things. For example, you can "assign" arrays, functions, and commands, as in Ship := Planet or NewLine := NewRectangle. This will, of course, break a lot of things. For example, when you do Ship := Planet, ships will no longer be accessible, and the expression Ship(3) will refer to planet #3. On the other hand, this can also be used for good, for example to pass a function name to another function ("function pointer" or "closure" as known from other programming languages). PCC2 doesn't yet block those things. See Experimental Features for details.