Records
a) The syntax of declarations in IMP80 differ from that in IMP9. They are of the form %record (format) ident, ... %record (format) %array ident, ... %record (format) %name ident, ... %record (format) %array %name ident, ... "format" is either the name of a record format previously described, the name of a record previously described or is the actual record format itself. Example: %record %format RF (%integer I, J, K) %record (RF) R and %record (%integer I, J, K) R are both valid and have the same effect, except that the first version declares a record format with identifier RF, which can be used elsewhere, clash with other identifiers, etc. Either of the above forms could be followed by the statement %record (R) P which would declare a record P, with the same format as that of R. To summarise: the keyword %record in IMP80 must either be followed by the keyword %format or by a bracketed format, format reference or record reference.
[This syntax change can cause difficulties when translating IMP9 programs: a routine spec such as %routine %spec NAME1(%record %name NAME2, ...) must now be converted to %routine %spec NAME1(%record (FORM2) %name NAME2, ...) The record format FORM2 is presumably declared somewhere in the program, since a record of this format is required in order to call the routine; but it might not be in scope at the routine spec statement, and may have to be moved so that it is.] %record %spec statements are not allowed in IMP80.
b) The syntax of %record %format statements has been extended to permit alternative formats, i.e. to enable all or part of a record to be interpreted in different ways. Example: %record %format RF(%integer A %or %byteinteger B, C, D %c %or %long %real E) %record (RF) R The record R can be considered to consist of an integer or three byte integers or a long real. Each alternative starts at the same address. Thus it follows that in %record %format RF2 (%byteintegerarray A(0:10) %or %c %string(10) S) %record (RF2) R2 R2_A(i) holds the ith character of string R2_S. Note that ALL the sub-fields in a record format must have distinct identifiers. In the first example above, the three alternatives were of different sizes. This is permitted: the alternatives have padding bytes appended to them to bring them up to the size of the largest. Thus when calculating the size of a record, use the size of the largest alternative. When only part of a record is to have alternative formats, the alternatives must be bracketed within the %record %format statement. Example: %record %format RF3 (%integer TYPE, %real RATIO, (%byte %integer %array A(1:20) %or %c %string(10) S %or %c %record (RF2) DATA), %string(*)%name SN) More than one set of alternatives can be given within a single record format; in addition, they can be nested. Redundant brackets round alternatives are allowed. c) Records can contain records. The format of such a record must have already been defined, or be explicit. [A record clearly cannot contain a record with the same format as it itself has.] Records can contain multi-dimensional arrays of fixed bounds, of any type. Records can contain record names. The format of such a record name can be the same as that of the record containing it; thus %record %format RF4(%integer X, %record (RF4) %name NEXT) is permitted.