CONCEPT types DESCRIPTION Variables can have the following types: o int An integer. Normally 32 bits or 64 bits signed, yielding a range of at least -2,147,483,648 to 2,147,483,647. The exact available range is given by the predefined macros __INT_MIN__ and __INT_MAX__. Integer values can be specified in decimal, in sedecimal when preceded by '0x' (e.g. 0x11), binary when preceeded by '0b' (e.g. 0b00010001), octal when preceded by '0o' (e.g. 0o21) and as character yielding the charset value for the character as the number to use (e.g. '0' yields 48 on ASCII machines). Character values are enclosed in single-quotes ('), with the sequence ''' returning the single-quote itself. Instead of the literal character an escape-sequence can be written between the single-quotes: \N : the character code N in decimal \0xN : the character code N in sedecimal \xN : the character code N in sedecimal \0oN : the character code N in octal \0bN : the character code N in binary \a : BEL (0x07) \b : Backspace (0x08) \t : Tab (0x09) \e : Escape (0x1b) \n : Newline (0x0a) \f : Formfeed (0x0c) \r : Carriage Return (0x0d) \: the given character o status OUTDATED - status was planned to be an optimized boolean format, but this was never actually implemented. status does work; however, since it is only an alias for type 'int', just use int. o string Strings in lpc are true strings, not arrays of characters as in C (and not pointers to strings). Strings are mutable -- that is, the contents of a string can be modified as needed. The text of a string is written between double-quotes ("). A string can written over several lines when the lineends are escaped (like a macro), however a better solution is to write one string per line and let the gamedriver concatenate them. String text typically consists of literal characters, but escape-sequences can be used instead of characters: \ : Carriage Return (0x0d) \ : ignored \ : ignored \ : ignored \N : the character code N in decimal \0xN : the character code N in sedecimal \xN : the character code N in sedecimal \0oN : the character code N in octal \0bN : the character code N in binary \uNNNN : Unicode character N in sedicimal \UNNNNNNNN: Unicode character N in sedicimal \a : BEL (0x07) \b : Backspace (0x08) \t : Tab (0x09) \e : Escape (0x1b) \n : Newline (0x0a) \f : Formfeed (0x0c) \r : Carriage Return (0x0d) \" : The double quote (") \: the given character Adjacent string literals are automatically concatenated by the driver when the LPC program is compiled. String literals joined with '+' are concatenated by the LPC compiler as well. o bytes Byte sequences are similar to strings. They offer the same operations, but cannot be mixed with strings. Byte sequence literals are written between double-quotes prefixed with a 'b' (e.g. b""). Adjacent byte sequence literals are automatically concatenated. The text is allowed to consist of ASCII characters (equivalent to bytes 0-127) and escape-sequences just like strings, with the exception of the \u and \U unicode escape sequences. o object Pointer to an object. Objects are always passed by reference. The type specification can include a program name that is a mandatory inherit of the given object: object "/std/room" var; This program name is only verified during runtime when runtime type checks are activated. See pragma(LPC). o lwobject Pointer to an lightweight object. Similar to objects lightweight objects are always passed by reference. The type specification can include a program name that is a mandatory inherit of the given object: lwobject "/lwo/data" var; This program name is only verified during runtime when runtime type checks are activated. See pragma(LPC). o array Pointer to a vector of values, which could also be an alist. Arrays take the form ({ n1, n2, n3 }) and may contain any type or a mix of types. Arrays are always passed by reference. Note that the size of arrays in LPC, unlike most programming languages, CAN be changed at run-time. o mapping An 'associative array' consisting of values indexed by keys. The indices can be any kind of datatype. Mappings take the form ([ key1: value1, key2: value2 ]). By default, mappings are passed by reference. o closure References to executable code, both to local functions, efuns and to functions compiled at run-time ("lambda closures"). o coroutine Holds the execution state of an asynchronous function. o symbol Identifier names, which in essence are quoted strings. They are used to compute lambda closures, e.g. instead of ({..., 'ident, ... }) you can write declare a 'symbol' variable foo, compute a value for it, and then create the closure as ({ ..., foo, ... }) o float A floating point number in the absolute range __FLOAT_MIN__ to __FLOAT_MAX__ (typically 2.2e-308 to 1.8e+308). Floating point numbers are signified by a '.' appearing, e.g. '1' is integer 1, but '1.' is floating-point 1 . o mixed A variable allowed to take a value of any type (int, string, object, array, mapping, float or closure). o struct A collection of values. See structs(LPC). o lpctype A type itself. See lpctypes(LPC). o union A range of types, either of which the variable can contain at runtime. See unions(LPC). All uninitialized variables have the value 0. The type of a variable is really only for documentation. Unless you define #pragma strong_types or rtt_checks, variables can actually be of any type and has no effect at all on the program. However, it's extremely bad style to declare one type but use another, so please try to avoid this. A pointer to a destructed object will always have the value 0. HISTORY The types lwobject and coroutine were introduced in LDMud 3.6.5. SEE ALSO alists(LPC), arrays(LPC), mappings(LPC), closures(LPC), coroutines(LPC), objects(LPC), structs(LPC), unions(LPC), lpctypes(E), typeof(E), get_type_info(E), inheritance(LPC), pragma(LPC), modifiers(LPC), escape(LPC)