external next up previous contents index
Next: MOO variables Up: 10.5 Variables and Values Previous: 10.5 Variables and Values

Values (by Andy Bakun)

 

Acknowledgement: This text is a formatted version of a message posted to *Teaching on WorldMOO by Andy Bakun.

There are 5 types of MOO values. They are:

   Type         Example         What typeof() returns
   --------------------------------------------------
   Number       3, 56, 1245     NUM
   Objects      #0, #-1, #200   OBJ
   Strings      "x", "foobar"   STR
   Errors       E_PERM, E_NACC  ERR
   Lists        {1, "bone", {}} LIST

Numbers

Numbers are represented just as they are anywhere else, literally. MOO numbers do not have delimiters in them, such as commas (,). An optional minus sign (-) can preceed the number, making it negitive. MOO stores numbers as 32 bit signed integers, meaning it can understand any number from -2147483648 to 2147483647, big enough (small enough) for most purposes. These two values are stored in $minint and $maxint for programing convience. Note that the properties of signed integers include the fact that $minint - 1 = $maxint, meaning it wrapps around... $maxint + 1 will wrap around to the negative numbers.

Objects

Objects in MOO are represented by a pound sign/hash mark (#) followed by a literal number. Object numbers behave the same way numbers do, there is a max object number that can be represented, and a minimum. (This is just to say that there are limits). Object numbers represent a named object in the MOO database. Not all object numbers are valid tho, a valid object being one that 'exists' (see help create()) in the database. Object numbers can't have math operations performed on them. Object numbers are not numbers, they are a constistant way to refer to certain sections of the database.

Strings

Strings are MOO values that can contain any printable character. Strings are represented by their delimiting characters, the double quote ("). Strings can be of any length. Certain operations can be performed on strings; concatenation can be performed with the addition operator (+). There are a number of builtin functions that handle strings. To include a double quote in a string, put a backslash (
) before it, like
", so, "
"" is a string that contains a single double quote, and """ is a syntax error. This is called "backslash escaping" a character. Any character can be "escaped" but it only makes sense to escape the double quote and the backslash.

Errors

Errors are a MOO type that are used when an error occurs. They are just like any other type and you can use them yourself in a program to represent errors and to pass between verbs (or whatever you want). Errors have both a short name, which is the actual error value, and a string value, which is a more descriptive form of the error. The value and string are not interchangable (E_PERM != tostr(E_PERM)) A string containing the error description can be found by using the tostr() builtin. Builtin functions return errors (how those errors behave is dependant on the d bit of the verb... verbs are to come later). All errors have E_ before their name. For a list of errors, see help errors While E_NONE means no error, it is still an error type.

Lists

Lists are like arrays in other languages. A list is a set MOO types inclosed in curly braces (). Any MOO type can be in a list, even other lists. Lists have a length, which can be found by using the builtin function length(). A list can have no elements in it, which is , and is called the empty list (sometimes called epsilon). length() == 0. You can find out what a certain element in a list is by using a number in square brackets ([]) after the list. 1,2,3 is list of length three, all three elements are numbers. 4, #4, E_PERM, is list of four elements, the fourth being an empty list.


next up previous contents index external
Next: MOO variables Up: 10.5 Variables and Values Previous: 10.5 Variables and Values

Daniel K. Schneider
Thu Apr 17 12:43:52 MET DST 1997