CS314 Fall 2007 Assignment 7 #1. The following expressions in a C-like PL describe constructed types. Write out the types of each variable using type constructors. For example, int *p would be written as Pointer(int) where int is the base type, and Pointer() is a type constructor that creates pointers to objects of its parameter type. Write out the types of each variable in the program given below: Explicitly state any assumptions you have to use. type ss 1..10 type tt 5..15 type s struct {int a1, ss a2} type t struct {int b1, tt b2} type w t[1..10] ss s1; tt s2; s y1; t y2; w h1; s *l1; #2. Assume your PL allows arrays of the form: a [1..10] [1..5,1..5], where arrays are stored in column major order. Show the array element address formula for a[j][k,l]. State any additional assumptions you have to make to obtain this formula. #3. Look at following pseudocode for procedure compute(). You can assume that this PL allows mixtures of parameter passing methods, as shown in the procedure definition. procedure compute(first:integer(by value), last:integer(by value), incr:integer(by value),term:double(by name),t:double(by name)) { ans:integer; ans := 0; term := first; while (term <= last) do ans := ans + t; term := term + incr; endwhile; return ans; } a. What is returned by the call compute(1, 10, 1, J, A[J])? b. What is returned by the call compute(1,5,1, J, 1/A[J])? c. Using your knowledge of how compute() works, can you write a procedure that calculates the maximun value from a set of values obtained by evaluating some expression containing a variable that ranges from a given lower bound to an upper bound with a given step size? You can assume the values are integers. #4. Write your own example for which pass by value-result and pass by reference have observably different effects. You need to make up your own example, different from any in our lecture notes.