Muq structures are modelled closely on those of CommonLisp, and are similar to Pascal's records and C's structs.
One thinks of a structure as being a chunk of storage divided into named slots, each capable of holding one value. A structure representing a person might, for example, have slots for name, age and sex:
__________________________ | Name "Pat" | __________________________ | Age 21 | __________________________ | Sex Yes | __________________________
Structures are simple, no-frills datastructures intended to supply this sort of functionality with a minimum of extra baggage.
Structures are the appropriate datastructure to use when either your needs are so simple that the extra machinery supplied by objects would be wasted, or else when you needs are so specialized that you prefer to construct the facilities you need yourself out of simple building blocks, in order to have maximum control over the time and space tradeoffs.
Structures are very similar to vectors, differing mainly in that vector slots are selected by small integers, whereas structure slots are selected by mnemonic names. Thus, vectors are a better choice if you often compute which slot to use on the fly, and structures are a better choice if you usually have a fixed number of slots each with a fixed and distinct meaning.
Go to the first, previous, next, last section, table of contents.