Contents    Page-10    Prev    Next    Page+10    Index   

Example of Structure Reference

Given the preceding declarations, the reference

would be processed as follows:

Reference Expression Type
people[i] aref(people, (i-1)*32) person
= aref(people, -32 + i*32)
.birth aref(people, (i-1)*32+16) date
= aref(people, -16 + i*32)
.day aref(people, (i-1)*32+16+4) 1..31
= aref(people, -12 + i*32)

It is useful to think of structure descriptions in nested Lisp-like form. For example, the preceding declarations would yield the following type for the array people:

(ARRAY (.. 1 100)
               (SS INTEGER)
               (BIRTH (RECORD
                        (MO (.. 1 12))
                        (DAY (.. 1 31))
                        (YEAR INTEGER)))))