cs375 p. 147

Contents Page-10 Prev Next Page+10 Index

Example of Structure Reference

Given the preceding declarations, the reference

 people[i].birth.day
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)
 (RECORD (NAME ALFA)
 (SS INTEGER)
 (BIRTH (RECORD
 (MO (.. 1 12))
 (DAY (.. 1 31))
 (YEAR INTEGER)))))

AltStyle によって変換されたページ (->オリジナル) /