Learn the details of variant records in Pascal. (a) You may have noticed that the language does

Question:

Learn the details of variant records in Pascal.

(a) You may have noticed that the language does not allow you to pass the tag field of a variant record to a subroutine by reference. Why not?

(b) Explain how you might implement dynamic semantic checks to catch references to uninitialized fields of a tagged variant record. Changing the value of the tag field should cause all fields of the variant part of the record to become uninitialized. Suppose you want to avoid adding flag fields within the record itself (e.g., to avoid changing the offsets of fields in a systems program). How much harder is your task?

(c) Explain how you might dynamic semantic checks to catch references to uninitialized fields of an untagged variant record. Any assignment to a field of a variant should cause all fields of other variants to become uninitialized. Any assignment that changes the record from one variant to another should also cause all other fields of the new variant to be uninitialized. Again, suppose you want to avoid adding flag fields within the untagged record itself. How much harder is your task?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: