Re: On the Square-Rectangle Problem
ram@zedat.fu-berlin.de (Stefan Ram) writes:
x e C ==> x e E (if x is a circle, then x is an ellipse)
R a C <== R a E (if R accepts ellipses, then R accepts circles)
This can also be put in this wording:
Let us call 0 and 1 ?small values?.
Let us call a function that accepts a small value as an
argument a ?small function?, while a function that accepts
any int argument an is called an ?int function?.
Then we have:
Every small value is an int value.
Every int function is a small function.
(Note the interchange of directions.)
Now, when we have a store, it can be set to a value:
store.set( value )
The set-function of a small store is a small function,
the set-function of an int store is an int function.
So the contravariance actually only holds for the
set functions of a storage object, while the get functions
(which return the stored value) are covariant.
So to avoid confusion one needs to talk about values
and functions.
Whole interfaces (i.e., sets of functions) might not be
covariant or contravariant, but a mixture of both
(with regard to a value type).