MUMPS Syntax - Variables and Datatypes

Variables and Datatypes

MUMPS does not require declaration of variables, and is untyped: all variables, including numbers, are effectively strings. Using variables in a numeric context (e.g., addition, subtraction) invokes a well-defined conversion in case the string is not a canonical number, such as "123 Main Street".

MUMPS has a large set of string manipulation operators, and its hierarchical variable management system extends to both RAM-based and disk-based variables. Disk resident (i.e., database) variables are automatically stored in hierarchical structures. Most implementations use caching, node indexes and name compression to reduce the time/space cost of disk references.

All variables are considered to be 'sparse' arrays. In a MUMPS context, this means that there is no requirement for sequential nodes to exist — A(1), A(99) and A(100) may be used without defining, allocating space for, or using any space for, nodes 2 through 98. Indeed, one can even use floating-point numbers and strings ( A(1.2), A(3.3), A("foo"), etc.) where the subscript names have some meaning external to the program. The access function $ORDER ( A(1.2) ) returns the next defined key or subscript value, 3.3 in this example, so the program can readily manage the data. Subscripts are always returned (and usually stored) in sorted order.

Given their sorting and naming features, it's not uncommon for subscript/variable names to be used as data stores themselves, independent of any data stored at their locations. This feature is often used for database indexes. E.g., SET ^INDEX(lastname,firstname,SSNumber)=RecordNum.

Read more about this topic:  MUMPS Syntax

Famous quotes containing the word variables:

    Science is feasible when the variables are few and can be enumerated; when their combinations are distinct and clear. We are tending toward the condition of science and aspiring to do it. The artist works out his own formulas; the interest of science lies in the art of making science.
    Paul Valéry (1871–1945)