Difference between revisions of "Replication"
(→Three cases of conforming repeated inheritance) |
(→Three cases of non-conforming repeated inheritance) |
||
Line 28: | Line 28: | ||
inherit {NONE} | inherit {NONE} | ||
B | B | ||
− | rename f as | + | rename f as f1, g as g1 end |
B | B | ||
− | rename f as | + | rename f as f2, g as g2 end |
feature | feature | ||
end | end | ||
</code> | </code> | ||
− | And an informal description of the semantics: An object of class D1 contains two physical attributes ( | + | And an informal description of the semantics: An object of class D1 contains two physical attributes (f1 and f2). A call to feature g1 results in f1 being incremented and a call to g2 increments f2. |
Lets do the same for D2: | Lets do the same for D2: | ||
Line 44: | Line 44: | ||
inherit {NONE} | inherit {NONE} | ||
B | B | ||
− | rename g as | + | rename g as g1 end |
B | B | ||
− | rename g as | + | rename g as g2 end |
feature | feature | ||
end | end | ||
</code> | </code> | ||
− | An object of class D2 contains one physical attribute (f). A call to either | + | An object of class D2 contains one physical attribute (f). A call to either g1 or g2 results in f being incremented. |
Class D3 should be rejected by the compiler: | Class D3 should be rejected by the compiler: | ||
Line 59: | Line 59: | ||
inherit {NONE} | inherit {NONE} | ||
B | B | ||
− | rename f as | + | rename f as f1 end |
B | B | ||
− | rename f as | + | rename f as f2 end |
feature | feature | ||
end | end | ||
</code> | </code> | ||
− | Since an object of class D3 would have two physical attributes | + | Since an object of class D3 would have two physical attributes f1 and f2, it is not clear which one g should increment. |
====Three cases of conforming repeated inheritance==== | ====Three cases of conforming repeated inheritance==== |
Revision as of 09:40, 25 August 2006
Work in progress!
We start with some very basic examples, for this we consider all the classes not to be inherited by ANY.
Contents
Example set
Basic cases of direct repeated inheritance
The following set of example will base on class B:
class B feature f: INTEGER g do f := f + 1 end end
Three cases of non-conforming repeated inheritance
Lets have look at D1 that repeatedly inherits from B:
class D1 inherit {NONE} B rename f as f1, g as g1 end B rename f as f2, g as g2 end feature end
And an informal description of the semantics: An object of class D1 contains two physical attributes (f1 and f2). A call to feature g1 results in f1 being incremented and a call to g2 increments f2.
Lets do the same for D2:
class D2 inherit {NONE} B rename g as g1 end B rename g as g2 end feature end
An object of class D2 contains one physical attribute (f). A call to either g1 or g2 results in f being incremented.
Class D3 should be rejected by the compiler:
class D3 inherit {NONE} B rename f as f1 end B rename f as f2 end feature end
Since an object of class D3 would have two physical attributes f1 and f2, it is not clear which one g should increment.
Three cases of conforming repeated inheritance
Lets look now at different variants of class DC1. They looks exactly as class D1 except that it inherits conforming from B (twice) and therefore need to solve the conflicts between f_1-f_2 and g_1-g_2 by selecting. Let DC1_f
Even though the following examples contain conforming inheritance, we will start by investigating their semantics in the case where static and dynamic type are equal.