program language pragmatics
-
Scott Text: Page 165. Exercise 3.6.
-
Scott Text: Page 167. Exercise 3.11.
-
Scott Text: Page 168. Exercise 3.14.
-
Scoper Class Exercise ( posted on Moodle)
-
TypeChecking Class Exercise. (posted on Moodle)
-
Scott Text: Page 317. Check you understanding 11,12,15,16,19
-
Scott Text: Page 370. Check your understanding 44,45,52,53
-
Scott Text: Page 373 Exercise 7.2.
-
Discuss assignment type compatibility in Java for numbers, Booleans, arrays and objects. Give examples of each.
-
Are there types in Scheme? How does Scheme do type checking? Give at least 3 different examples of Scheme functions that have type errors.
-
Are Scheme vectors mutable or immutable? Are Scheme lists mutable or immutable? Discuss. Use Dr Racket as a reference.
-
What is printed if y is passed by value? What is printed if y is passed by reference?
int f ( int y) { int t = y; y = t * y; return t; }
void main() { int a = 6; print f(a); print a; }
-
What is printed if y is passed by value? What is printed if y is passed by reference?
void g ( int[] y) { y[0] = 9; y[1] = y[0] + 1; }
void main() { int [] a = { 2,4,6,8}; g(a); print( a[0] + a[1]); }
-
What is printed if y is passed by value? What is printed if y is passed by value-result? What is printed if y is passed by reference?
double a = 2.0; //global
double f ( double y) { double x; y = a + y; x = a; ; return y* x; }
void main() { print f(a); print a; }
-
What is printed if v and w are passed by value? What is printed if v and w are passed by reference as in Java? Assume that Person is an object with a name and age field. Assume that print prints the fields of the object.
void f ( Person v , Person w ) { v.age = w.age; v = w; w.age = v.age *3; }
void main() { Person p1 = new Person (“Lin”, 20) ;
Person p2 = new Person(“Ann”, 40); f( p1, p2); print p1; print p2; }
-
Write a small Scheme function that has a function parameter.
-
Write a small Scheme function that returns a function.
-
How do you describe as a type in C++ a pointer to a function that takes two ints as arguments and returns a double?
-
What is a generic subprogram in Java? What are its advantages?
-
Be able to determine type and value of Java expressions given variable values and types. See example in Power Points for Chapter 7. (Approximately slide 24).