The problems in io type (not finished)

zhaozj2021-02-16  56

TYPING OF

?

Encapsulation (Solved: "existential type" [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.

转载请注明原文地址:https://www.9cbs.com/read-21046.html

New Post(0)