Computer Science & Engineering 505
Concepts of Programming Languages
Assignment 7

Nov 21, 1994
Due: November 30, 1994


  1. In class we noted that the typechecker for the little functional language defined in Cardelli's paper "A Semantics of Multiple Inheritance" is more conservative than the dynamically typed version.
    1. Give an example of a program that fails the typechecker but that will run successfully if there is no typechecking.
    2. Can the definition of the semantic function given on page 10 be modified so that a program will pass the typechecker in exactly those cases where it does not output a value of "wrong"? Leave the type inference rules unaltered. If so, how should the semantic function be modified? (Hint: Make sure in this case that the language still behaves reasonably. In particular, make sure you can still write a terminating 'factorial' function.) If the semantic equations can't be modified in this way, why not?
    3. Conversely, can the type function on page 11 and the inference rules given on page 12 be modified so that a program will pass the typechecker in exactly those cases where it does not output a value of "wrong"? (Leave the semantic function unaltered.) If so, what are the modifications to the type function and inference rules? If not, why not?

  2. Cardelli's language has call-by-value semantics. Give the necessary modifications to the semantic equations to give it call-by-name semantics.

  3. On page 216 of the Bracha and Griswold paper on Strongtalk they state "a straightforward type system can enormously complicate such seemingly mundane tasks as passing an array of strings to a method that needs a read-only array of any type of object." What are they talking about here?

  4. Consider the Binary Tree2 solution to question 2 on Assignment #4. (This is the problem in which BinaryTree is a subclass of Collection.) Give the Strongtalk protocol for BinaryNode and BinaryTree. (If you need to make up some protocols for other kinds of classes in the process, go ahead and do so, describing what you did and why.)

  5. Strongtalk uses structural rather than name equivalence. However, in the lecture notes on Ada, it was argued that modified name equivalence (e.g. as used in Ada) as a better choice than structural equivalence (e.g. as used in Algol-68). Discuss. Is one of these design decisions the wrong one? Is there something different about object-oriented type systems that makes structural equivalence better? Do Bracha and Griswold repair the deficiencies of structural equivalence? Or what?