In object-oriented terminology, covariance relates to rewritten methods, and what types are allowed. The Eiffel FAQ provides this example of two classes: a PARENT class and a CHILD class, with the child class rewriting the foo method.
class PARENT
feature
foo (arg: A) is ...
end; -- PARENT
class CHILD
inherit
PARENT redefine foo
feature
foo (arg: B) is ...
end; -- CHILD
The question is: what relationship between the types A and B should be allowed? There are 3 possible answers:
- They're always the same
- B is a subtype of A -- this is covariance, since the classes and the method parameters move (vary) in the same "direction", ie down the inheritance hierarchy.
- A is a subtype of B -- the contravariance rule. The classes and the parameters move in different directions.
Sather is contravariant, while Eiffel is covariant.