Your name:
clam
, and another method mollusc
, as follows:
clam
message to an instance of
A? To an instance of B? To an instance of C?
ConsCell
. Cons
cells should understand the following messages:
car
-- return the first element of the list
cdr
-- return the rest of the list (which of course might
be the empty list)
car:
-- set the first element of the list to a new value
cdr:
-- set the rest of the list to a new value
do:
-- this message takes a block as an argument, and
evaluates the block on each element of the list
How are you representing the empty list? Say why you chose that
representation, and compare it with alternative possibilities. Give
code that constructs the list (1 2 3), and show how to print each element
in the list to the Transcript using do:
.
ConsCell
were implemented in Bracha
and Griswold's Strongtalk system. Show the generic protocol for
ConsCell
.
ConsCell
, is "list of integer" a subtype of "list of number"?
Is "list of number" a subtype of "list of integer"? Why?
What would the relation be if Strongtalk used the covariant rule instead of the contravariant rule?
car
message. (In particular describe what messages are
delegated to what).
Describe how the search for a method is performed given a message sent to an instance of D.
append
in Prolog.