Typing of
? Encapsulation (Solved: “existential types” [Girard 71])
? Inheritance (Partially solved)
?
Polymorphism (Open issue) Typing Inheritance
1.
Covariant Typing
Animal {
Shit eats(Food)
}
Cow extends Animal {
CowShit eats(Grass)
}
Problem: Not type sound
Animal a = new Cow();
Food f = new Hamburger();
a.eat(f); //Food poisoning
2.
Contravariant Typing
Animal {
Shit eats(Grass)
}
Cow extends Animal {
CowShit eats(Food)
}
Problem:
Sound but not flexible
3.
Novariant Typing
Animal {
Shit eats(Food)
}
Cow extends Animal {
Shit eats(Food)
}
Problem:
Worst of both worlds.