Consider the computation of
(program-all-defined? (list (make-def 'f1 (list 'x) (make-appexp 'f2 (list (make-varexp 'x)))) (make-def 'f2 (list 'x 'y) (make-appexp 'f2 (list (make-varexp 'z) (make-varexp 'y)))) (make-def 'f3 (list 'x 'y 'z) (make-appexp 'f1 (list (make-appexp 'f2 (list (make-varexp 'z) (make-varexp 'y))) (make-varexp 'x))))))
Which of the following will appear as calls during this computation?
Answer: There are two occurrences of (make-varexp 'z) in this program-- one in the definition of f2 and one in the definition of definition of f3.
According to the definition of defs-all-defined?, the variables appear in vars in the following order:
Answer (1) does not occur and does not satisfy the invariant, because z does not occur in the definition of f1.
Answer (2) occurs for the use of z in f3. It satisfies the invariant.
Answer (3) does not occur and does not satisfy the invariant. There is no occurrence of z for which these are the available variables.
Answer (4) does not occur, but it does satisfy the invariant. These are exactly the variables that are available for the occurrence of z in f3, but this is not the order in which the variables are listed in the algorithm (compare with answer (2)).
Last modified: Mon Oct 17 16:38:34 Eastern Daylight Time 2016