6.1.2 Record Types

Records are collections of elements of heterogeneous types. The best way to see this is to define an example.

type element_record = record [ name : array [ character ];
                               number : integer;
                               weight : real ]
type atomic_table = array [ element_record ];
Here we see a record type for chemical elements, containing fields for a name, atomic number, and atomic weight, with each field having a different type. We also see an array type for a collection of element records. Such aggregations can be nested to effectively any useful depth.

The fields of record-type data items are accessed by giving the name of the record-type value, followed by a period and the field name. Given the above declarations, suppose we have the value Fe, of type element_record. Then specifying Fe.name could yield the value "Iron" and specifying Fe.number could yield the value 56. For a value named Column1 of type atomic_table, we might have the access Column1[1] yield a record of type element_record whose contents are [name: "Hydrogen"; number: 1; weight: 1.0].

In practice, records usually are aggregated into arrays, and they sometimes contain array-type fields. This is natural, convenient, and will be familiar to users of languages such as Pascal. While some of the standard uses for records, such as implementing stacks and queues, can be accomplished with arrays of records, they can also be done using another built-in aggregate type called a "stream." Streams will not be dealt with here, and the interested reader is referred to the Sisal Language Manual [33].



Previous Section



Next Section



Table of Contents




If you have any questions about this page, or want more information about the Sisal Language Project, contact:
John Feo at (510) 422-6389 or feo@diego.llnl.gov, or Tom DeBoni at (510) 423-3793 or deboni@llnl.gov.

The Sisal Language Project has been approved as a Designated Unclassified Subject Area (DUSA) K19222, as of 07 August, 1991.

LLNL Disclaimer
UCRL-MI-122601