CS314 Fall 2007 Asignment 8 Imagine that in a programming language, arrays have their bounds as part of their type; that is, [1:10]int is the not the same type as [0:9]int. /* type definitions */ type vector [1:10] int; type matrix [1:10] vector; type mm [1:10,1:10] int; type zz [1:10] vector; type yy [0:9] vector; type ss 1..10; type tt 5..7 type integ int type s struct {int a1; ss t}; type z struct {ss t1, ss t2}; type w struct {int v, int u} type q struct {integ a2; ss a3}; /* variable declarations */ mm c,d; zz a,b; yy e,f vector v1,v2; matrix m1, m2; ss t1,t2; tt t3,t4; int t5; integ t6; s c1; z c3; w c4; q c2; a. If we use structural equivalence for comparing types, group these variables into sets where each set of variables has the same type: {c,d,a,b,e,f,v1,v2,m1,m2,t1,t2,t3,t4,t5,t6,c1,c2,c3,c4}. b. Show the groupings of the variables which would occur if we used name equivalence: {c,d,a,b,e,f,v1,v2,m1,m2,t1,t2,t3,t4,t5,t6,c1,c2,c3,c4}. c. Assume that the following statements are legal in some programming language. For each statement, tell if it could be type checked at compile-time or run-time; briefly give a reason for your answer. (Note: the general rule is coercion can occur if there is no loss of precision in the implicit conversion.) /* assignment statements */ m1[t1] = m2[t2]; t2 = t4; t5 = t3; c1.a1 = c4.v; c1.a1 = m1[t5,t5+1]; c4.v = c3.t1; t3 = t1; t5 = v1[2];