Homework 4 Due Tuesday, March 17 at 1:00 PM NOTE: This homework is optional. If you turn it in, your lowest homework grade will be dropped. 1) Answer the following questions about parameter passing: (a) What are formal parameters? (b) What are actual paramaters? (c) What are the three semantic models of parameter passing? (Hint: these are the parameter modes available in Ada.) (d) In what ways can aliases occur with pass-by-reference parameters? 2) Consider the following program written in a ALGOL-like language: procedure BLAH; integer GLOBAL; integer array LIST[1:3]; procedure FOO (P1, P2); integer P1, P2; begin GLOBAL := P2; P2 := P1; P1 := 7; GLOBAL := 1 end; begin LIST[1] := 3; LIST[2] := 5; LIST[3] := 2; GLOBAL := 1; FOO (LIST(GLOBAL),LIST[3]); FOO (GLOBAL, LIST[2]); end; Hand execute the program under the following assumptions, and compare the resulting values in the array LIST and the variable GLOBAL in BLAH after each return from FOO. a) Parameters are passed by value. b) Parameters are passed by reference. b) Parameters are passed by name. b) Parameters are passed by value-result. HINT: See http://www.cc.gatech.edu/classes/cs3411_97_winter/homework4-ans.txt for answers to problems similar to 3 and 4. 3) Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in the following skeletal program: procedure BLAH; procedure A; procedure B; begin {B} ... <------------ 1 end; {B} begin {A} ... B ; ... end; {A} procedure C; begin {C} ... A; ... end; {C} begin {BLAH} ... C; ... end; {BLAH} 4) For the skeletal program in Problem 3, show the display that would be active at position 1, along with the activation records on the stack.