Data Types

An object's properties can be of several different types. One might be a number, or a string of characters, or an object number, or a list of things. These data types are used throughout MOO building and MOO code.

You've already seen some data types. The "first verb" used "player" and "this," which are both objects. You also saw some text sent to various people, which involved strings. MOO has relatively few types, and it's fairly easy to get to know all of them.

Programmer's Note: Variables in MOO aren't declared with a type, and any value can occupy any variable regardless of the type it previously held. In contrast, MOO strongly restricts binary operations with mixed types, to the point that even trying to add an integer to a floating point raises an error. There's also only one type of int, only one float, etc. Again, this is arguably wasteful, but good for a teaching language.

Data Type Chart

Type Examples Null
Integer 0, 3, 182734 0
Floating Point0.0, 3.2, 178.3, 214.00.0
Object #0, #1723, #5812 n/a
String "a", "Hello", " " ""
MOOlist {1}, {1, 2, 3}, {"a", "c"} {}

Briefly, let's go through each type and describe some of the characteristics.

Integer (INT)

The integer type is simply any negative or positive whole number. They never have decimals or fractional parts, and computers find them extremely easy to process.

Integers are restricted to the range -2147483648 to 2147483647.

Floating Point (FLOAT)

The floating point type is any number with a decimal, even if the decimal is ".0". It is important to remember that integers and floats are very different data types, and are not interchangeable. Floats are much more difficult to process than ints, though you probably won't ever notice the speed difference. Their range isn't so restrictive that you'll probably ever have to worry about it.

Object (OBJ)

The object type includes all potential object numbers, even if they don't happen to be associated with a valid object. You'll almost always use them to refer to actual objects.

There are also three special object numbers: #-1 ($nothing), #-2, ($ambiguous_match), and #-3 ($failed_match). You won't have to worry about these for a while.

Object numbers have no null value. Every object number is considered "false".

String (STR)

Strings are our first complex data type -- called "complex" because it holds more than one item. The items in this case are characters: letters, numbers, and various symbols. Strings can hold any individual character, sentences, paragraphs, or nothing at all.

MOOlist (LIST)

MOOlists (or just lists) are also complex, like strings, again because it holds more than one item. The items in this case can be anything at all -- integers, floats, objects, strings, other lists -- in any number or combination. Lists are an especially complex topic, and there will be a lot more about them later.

Programmer's Note: MOOlists are similar but not the same as arrays. MOOlists can hold any data type, or more than one, in any combination. MOO programmers don't have to worry about dynamic or static, or defining length, or most of the other things that make them confusing in other languages. Manipulating them is extremely easy. They're also 1-based.