program language pragmatics

program language pragmatics

 

  1. Scott Text:  Page 165. Exercise 3.6.

  2. Scott Text:  Page 167. Exercise 3.11.

  3. Scott Text:  Page 168. Exercise 3.14.

  4. Scoper Class Exercise  ( posted on Moodle)

  5. TypeChecking Class Exercise. (posted on Moodle)

  6. Scott Text:  Page 317. Check you understanding 11,12,15,16,19

  7. Scott Text: Page 370. Check your understanding 44,45,52,53

  8. Scott Text:  Page 373  Exercise 7.2.

  9. Discuss assignment type compatibility in Java for numbers, Booleans, arrays and objects. Give examples of each.

  10. Are there types in Scheme? How does Scheme do type checking?  Give at least 3 different examples of Scheme functions that have type errors.

  11. Are Scheme vectors mutable or immutable?  Are Scheme lists mutable or immutable? Discuss. Use  Dr Racket as a reference.

  12. 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; }

     

  13. 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]);    }

     

  14. 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; }

     

     

  15. 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;   }

     

  16. Write a small Scheme function that has a function parameter.

  17. Write a small Scheme function that returns a function.

  18. How do you describe as a type in C++ a pointer to a function that takes two ints as arguments and returns a double?

  19. What is a generic subprogram in Java? What are its advantages?

  20. 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).

 

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon
"FIRST15"

Order Now