This worksheet will not be graded, but you should think about and write out answers to these questions.
As you read the Abstraction Mechanisms in CLU paper, attempt to answer the following questions:
p. 230: cvt is an unnecessary but useful syntax for making programs more compact. CLU automatically defines:
up = proc (rep) returns (wordbag)Rewrite the implementations of wordbag$create and wordbag$insert without using cvt.
down = proc (wordbag) returns (rep)
p. 231, footnote 3: Explains why it is necessary for wordbag$insert to return a value. Could a different representation be used to make this unnecessary?
p. 231, Figure 4: Unlike Pascal and Algol68, CLU is able to define a recursive data representation without the need for explicit references. What is it about CLU's semantics that allows this? (Hint is on next page.)
p. 232: Is it possible to implement a mutable data type using an immutable representation? Is it possible to implement an immutable data type using a mutable representation?
p. 232: "These restrictions, plus the restriction that only the code in a cluster may use cvt to convert between the abstract and representation types, ensure that the behavior of an object is indeed characterized completely by the operations of its type." Is this correct? Are any other requirements on data type implementations necessary to guarantee this?
p. 233: If you already have experience with an object-oriented language that supports subtyping, consider the differences between subtypes (or Java interfaces) and where clauses. (We'll read a paper on this later.)
p. 234-235: Imagine writing the same program using Java or C++.
p. 236-237: Should data abstraction fundamentally make a program execution slower or faster?
University of Virginia
CS 655: Programming Languages