Overview of MUMPS
Posted on:3/24/2006
| MUMPS is a language designed for building database applications. Secondary language features are designed to help programmers make applications that use as few computing resources as possible. |
MUMPS is a language designed for building database applications. Secondary language features are designed to help programmers make applications that use as few computing resources as possible. Original implementations were interpreted, though modern implementations may be either fully or partially compiled.
The core feature of MUMPS is that database interaction is transparently built into the language. Simply by using variables prefixed with a caret '^' character, you are referencing a database node. Assignment and retrieval uses the same commands as for interacting with standard RAM-based variables. Additionally, all variables (both RAM and database-based) can be treated as a multidimensional hash/array. Child nodes of a variable (called subscripts in M) can have numeric or string keys (the keys themselves are also called subscripts, such that with the variable name ^A("B",2,6), "B", 2 and 6 are the first, second and third subscripts of ^A). String keys are automatically stored in alphabetical order following all numeric keys. Numeric keys can have negative and/or floating-point values, all of which will be stored in order from lowest to highest. The MUMPS terminology for database-linked variables is a global, not to be confused with the C term for unscoped variables (see Variable scoping).
As a secondary language feature, you can abbreviate nearly all commands and native functions down to a single character to save space. Additionally, special operators exist to let you treat a delimited string (like Comma-separated values) as an array. To reduce the number of hard-disk reads, early MUMPS programmers would store a structure of related information as a delimited string, parsing it out after it was read.
MUMPS has no data types. Numbers can be treated as strings of digits, strings can be cast (coerced, in MUMPS terminology) into numbers by numeric operators. When a string is coerced, the parser turns as much of the string (starting from the left) into a number as it can, then discards the rest. Thus the statement 'IF 20<"30 DUCKS"' is evaluated as TRUE in MUMPS.
Other features of the language standard are designed to help applications interact with each other in a multi-user environment. Database locks, process identifiers and Atomicity of database update transactions are all required of MUMPS implementations that follow the standard.
In contrast to languages based on C, whitespace is signifant. A single space separates a command from its argument, and a space or newline separates the argument from the next command. Commands that take no arguments (like ELSE) require two following spaces; one to separate it from its (nonexistent) argument, then another to separate the "argument" from the next command. Newlines are also significant; an IF, ELSE or FOR command processes/skips everything else on the line. To make them affect multiple lines, you must use the DO command to create a block.
All text is available under the terms of the GNU Free Documentation License (see Copyrights for details).