Certain languages. like Lisp, have the ability to return newly created procedures at run time. In Fig.7.56. all functions, whether defined in the source text or created at run time, take at most one argument and return one value, either a function or a real. The operator 0 stands for composition of functions; that is (fog)( x) ::= f (g (x) ) .
a) What value is printed by main?
*b) Suppose that whenever a procedure p is created and returned, its activation record becomes a child of the activation record of the function returning p. The passing environment of p can then be maintained by keeping a tree of activation records rather than a stack. What is the tree of activation records when a is computed by main in Fig. 7.56?
*c) Alternatively. suppose an activation record for p is created when p is activated , and made a child of the activation record for the procedure calling p, This approach can be used to maintain the activation environment for p. Draw snapshots of the activation records and their parent-child relationships as the statements in main are executed is s a stack sufficient to hold activation records when this approach is used?