Content deleted Content added
→Inheritance in object-oriented languages: +{{Dubious}} "invariance" Tag: Reverted |
→Function types: Fixed unmatched parentheses |
||
Line 107:
{{cite conference |first=Luca |last=Cardelli |title=A semantics of multiple inheritance |conference=Semantics of Data Types (International Symposium Sophia-Antipolis, France, June 27–29, 1984) |year=1984 |url=http://lucacardelli.name/Papers/Inheritance%20(Semantics%20of%20Data%20Types).pdf |series=Lecture Notes in Computer Science |volume=173 |publisher=Springer |pages=51–67 |isbn=3-540-13346-1 |doi=10.1007/3-540-13346-1_2}}<br/>Longer version: {{cite journal |author-mask=1 |first=Luca |last=Cardelli |title=A semantics of multiple inheritance |journal=Information and Computation |volume=76 |issue=2/3 |pages=138–164 |date=February 1988 |doi=10.1016/0890-5401(88)90007-7 |citeseerx=10.1.1.116.1298}}</ref>
When dealing with [[Higher-order function|functions that take functions as arguments]], this rule can be applied several times. For example, by applying the rule twice, we see that <math>((P_1 \to R) \to R) \le ((P_2 \to R) \to R)</math> if <math>P_1 \le P_2</math>. In other words, the type <math>((A \to B) \to C)</math> is ''covariant'' in the position of <math>A</math>. For complicated types it can be confusing to mentally trace why a given type specialization is or isn't type-safe, but it is easy to calculate which positions are co- and contravariant: a position is covariant if it is on the left side of an even number of arrows applying to it.
== Inheritance in object-oriented languages ==
|