Difference between revisions of "Replication"

(8.16.3 Definition: Replication, Replica)
(8.16.3 Definition: Replication, Replica)
Line 129: Line 129:
 
</code>
 
</code>
 
|}
 
|}
* Feature ''f1'' of class ''D'' (whose body is in class ''C'') is not '''replicated''' in class ''D''.
+
* Feature ''f1'' of class ''D'' is not '''replicated''' in class ''D''.
* Feature ''f2'' of class ''D'' (whose body is in class ''D'') is not '''replicated''' in class ''D''.
+
* Feature ''f2'' of class ''D'' is not '''replicated''' in class ''D''.
* Feature ''f3'' of class ''D'' (whose body is in class ''B'') is '''replicated''' in class ''D'', since feature ''f2'' of class ''B'' is a version of it.
+
* Feature ''f3'' of class ''D'' is '''replicated''' in class ''D''. Feature ''f3'' of class ''D'' is a '''replicate''' of feature ''f'' of class ''B''
  
 
====8.16.X Validity: '''replicated''' feature====
 
====8.16.X Validity: '''replicated''' feature====

Revision as of 08:39, 28 September 2006

Author: Matthias Konrad

Known problems of the following text: Calls to targets of type like Current do not include usage of an attribute when it is assigned to.


One definition of replication is: the action or process of reproducing or duplicating.

Both ETL, OOSC2 and the standard use the term replication as if its semantics were common knowledge. I disagree to that, since I was not able to get consistent information about replication from notable experts. Hence it is certainly a term to be defined much more carefully.

Although not explicitly stated, it seems that a replicated feature has an unfolded form. That would mean, that we could get rid of replication by reducing it to other language mechanisms (As it is done for precursors). This is how the current ISE compiler (5.7 and earlier) handles replication (won't help us here since it doesn't comply to the standard).

If an unfolded form cannot be found, this has a huge impact on the standards text. The semantics of unqualified calls in the context of replicated features would for example not be defined.

Talking about features

Before digging into the replication rules we need a clear understanding of a feature.

There is a one to one connection between feature and Feature_body. Every feature has exacly one body. Every body belongs to exactly one feature. Meaning that, two different bodies belong to two different features and two different features have two different bodies.

Have a look at this example:

class
   B
feature
   f do ... end
end
class
   D
inherit
   B
      rename f as f1 select f1 end
   B
      rename f as f2 redefine f2 end
feature
   f2 do ... end
end

The following sentences apply to the above system:

  • The system has two features.
  • The feature named f1 in class D and the feature named f in class B are one and the same feature.
  • Feature f1 of class D and feature f of class B are the same feature.
  • Feature f2 of class D or the feature named f2 in class D. This feature has its body defined in class D.

By saying feature, we indirectly reference a certain Feature_body. Indirectly, because we can say: "feature f of a class D", when the Feature_body of f belongs to an Ancestor class A of D (Given that f is not redeclared on the inheritance path between A and D).

The name of feature f is always the name stated in its Feature_body. A feature may have different names in different classes (through renaming). It is thus legal to say: "Feature f with name fn in class D, when feature f is renamed to fn somewhere along the according inheritance path.

When we talk about feature bodies we are not strictly boud to the bodies occuring in the programms text. We may also denote the bodies that are results of folded forms. Examples are the body of a synonym or the body of a call-equivalent of an inline-agent or the body of a replicate as we will later see.

Inherited, redeclared and immediate features

Definition 8.5.1 should be changed to something with the following semantics:

8.5.1 Definition: Inherited, immediate; origin; redeclared; replicated introduce

Any feature f of a class C is of one of the following four kinds:

  1. If C obtains f from one of its parents, f is an inherited feature of C. In this case any declaration of f in C (adapting the original properties of f for C) is a redeclaration.
  2. If a declaration appearing in C applies to a feature that is not inherited, the feature is said to be immediate in C. Then C is the origin (short for “class of origin”) of f, and is said to introduce f.

Version

A version of a feature f is a feature f2 different from f that is a redeclaration from either f or a version of f.

New and modified rules

In the following a set of rules are given that are meant to replace rules 8.16.2 through 8.16.5.

8.16.2 Semantics: Repeated Inheritance rule

This rule will be obsolete but some thing similar might be introduced as informal text.

8.16.3 Definition: Replication, Replica

Let:

  • Class D have a parent part P1 lists class B1.
  • f be a non-deferred feature of class B1
  • Let P1 be such, that it changes the name of feature f to fn (With our without renaming) but doesn't have a redefine clause for fn.

The feature fr of class C with name fn is replicated iif one of the following holds:

  • Class D has a parent part P2 (different from P1) that lists class B2, such that B2 contains feature f and P2 changes its name to fn2 (different from fn) but doesn't redefine it.

or

  • Class D has a feature fg different from fr that is a version of feature f.

So feature fr is either replicated and is thus called a replica of feature f. When it is not replicated, feature f and fr are the same (Not just equal, but one and the same feature).

Informal:

  • Example:
class
   B
feature
   f do ... end
end
class
   C
inherit
   B
      rename f as f1 redefine f1 end
feature
   f1 do ... end
end
class
   D
inherit
   C
      select f1 end
   B 
      rename f as f2 redefine f2 end
   B
      rename f as f3 end
feature
   f2 do ... end
end
  • Feature f1 of class D is not replicated in class D.
  • Feature f2 of class D is not replicated in class D.
  • Feature f3 of class D is replicated in class D. Feature f3 of class D is a replicate of feature f of class B

8.16.X Validity: replicated feature

Let feature f with name fn in class D be replicated in D. Let P1...Pn be the parent clauses through which D inherits feature f with name fn.

Feature f is valid in class D if and only if it satisfies the following:

Every feature m that is used in f on a target of type like Current must be inherited through clauses P1...Pn with the same name.

Informal:

  • Example:
class
   B
feature
   f do g end
   g do ... end
 
end
class
   D
inherit
   B
      rename f as f1, rename g as g1, select f1, g1 end
   B
      rename f as f2, g as g2 end 
   B
      rename f as f2, g as g3 end
feature
   f1 do ... end
end

There are several features that are replicated in D: f1, g1, f2, g2, g3. Only f2 is not a valid replicated feature in D. It is inherited through the second and third parent part and has a call to g (with target of type like Current). Since g of class B is inherited with a different name through the second and third parent part the system is not valid.

8.16.X Semantics: Replication

Let:

  • feature f with name fn in class D be replicated in class D.
  • P1...Pn be the parent clauses through which D inherits feature f with name fn.
  • B be the class that contains the body of f.
  • CP be one of the conformance paths from B to D that enter D through the parent parts P1.

Feature f has a replicate in class D. This replicate is a new feature that redefines f in the parent clauses P1,...,Pn and is thus a version of f.

The replicate has the following properties:

  • The replicate of f and f have the same signature.
  • The name of the replicate is fn.
  • The body of the replicate is a modified copy of the body of f. The feature names that are used with targets of type like current are renamed according to the renamings that occur on the conformance path CP.
  • The replicate has no own pre- or post-condition.

Informative:

  • The validity rule of not isolated features warrant, that all the conformance paths from B over P1..Pn to D yield the the same renamings.
  • Example:
class
   B
feature
   f do g end
   g do end
end
class
   D
inherit
   B
      rename f as f1, g as g1 redefine f1 select f1, g1 end
      rename f as f2, g as g2 end
feature
   f1 do ... end
end

The not isolated features of class D are g1, f1 and g2. The following snippet shows class D with all its not isolated features unfolded:

class
   D
inherit
   B
      rename f as f1, g as g1 redefine f1, g1 select f1, g1 end
      rename f as f2, g as g2 redefine f2, g2 end
feature
   f1 do ... end 
   g1 do end    --I am a replicate!
   f2 do g2 end --Me to
   g2 do end    --Me to
end

8.16.4 Validity: Call Sharing rule

(The rule described here would replace 8.16.4. Maybe an other name is needed for the rule)

It is valid for a feature f declared in class B and isolated in class D to use feature g of A on a target of type like Current if and only if there is exactly one version of g in D.

Informative:

  • This rule implies one very simple property of calls to targets of type like Current, they are not influenced by selects.
  • Example of an invalid System according to this rule:
class
   B
feature
   f
      do g end
   g  do ... end
end
class
   D
inherit
   B
      rename g as g1 redefine g1 select g1 end
   B
      rename g as g2 redefine g2 end
feature
   g1 do ... end
   g2 do ... end
end

Feature f is inherited by class D from ancestor A. The feature involves an unqualified call to feature g. Since feature g has two versions in D (g1 and g2) the system is invalid. If f would be renamed in one or both the parent parts, the system could be made valid.

8.16.5 Semantics: Replication Semantics rule

Rather than a semantic rule this is a consequence of all the not isolated features of a class being unfolded.