## CHAPTER 7 

## Record Types 

Record types are perhaps the most flexible of data constructs. Conceptually, a record type is a template for a structure whose parts may have quite distinct characteristics. For example, assume we wish to record information about a person. Known are the name, height, sex, date of birth, number of dependents, and marital status. Furthermore, if the person is married or widowed, the date of the (last) marriage is given; if divorced, the date of the (most recent) divorce and whether this is the first divorce or not; and if single, no other information is of interest. All of this information can be expressed in a single "record," and each piece of information can be accessed separately. 

## 7.A. Fixed Records 

More formally, a record is a structure consisting of a fixed number of components, called fields. Unlike the array, components of a record type can have different types and cannot be indexed by an expression. A record-type definition specifies for each component its type and an identifier, the field identifier, to denote it. The scope of a field identifier is the innermost record in which it is defined. The two operations valid for entire record variables are assignment and selection of components. 

In order that the type of selected component be evident from the program text (without executing the program), the record selector consists of fixed field identifiers rather than a computable index value. 

