DynBindModel: Difference between revisions

From EiffelStudio: an EiffelSoftware project
Jump to navigation Jump to search
Konradm (talk | contribs)
Konradm (talk | contribs)
Line 66: Line 66:
<math>{\beta_S}^\prime: \left( \mathrm{TYPE} \times \mathrm{TYPE} \right) \rightarrow\left( \mathrm{NAME} \leftrightarrow\mathrm{NAME} \right)</math>
<math>{\beta_S}^\prime: \left( \mathrm{TYPE} \times \mathrm{TYPE} \right) \rightarrow\left( \mathrm{NAME} \leftrightarrow\mathrm{NAME} \right)</math>


We will give a recursive definition of <math>\beta_S</math>two relations. Meaning that we will give <math>\beta_{C_1,\ldots C_m}</math> given that we already now <math>\beta_{C_1,\ldots C_{m-1}}</math>
We will give a recursive definition of <math>\mathsf{\beta_S}</math>. Meaning that we will give <math>\beta_{ \left\{ C_1,\ldots C_m \right\} }</math> given that we already now <math>\beta_{ \left\{ C_1,\ldots C_{m-1} \right\} }</math>
 
This is valid since:
 
<math>\beta_{ \left\{ C_1 \right\} } \subseteq \beta_{ \left\{ C_1, C_2 \right\} } \subseteq \ldots  \beta_S</math>  





Revision as of 17:32, 2 October 2006

Motivation:

Eiffels dynamic binding is somewhat more complex than that of other languages. Its structure is still very simple and can be described by giving the relation:

γ:(TYPE×NAME)→(TYPE→FEATURE)

Relation γ contains both the static and dynamic binding part of the language. In the following feature:

f (a: ANY)
   do
      print (a.out)
   end

The static binding part of call a.out can be decribed as:

γ(ANY↦out)

Namely an evaluation of γ with a tuple containing the static type of the call and the name. The result of this is a function. This function will be evaluated at runtime and yield the right feature according to the dynamic type of a.

In the rest of this text, the we will show how to construct the relation γ based on any given eiffel system.

Some fundamentals

We introduce the operator > as the "ancestor of" and < as "descendant of" operator.

Without loss of generality we can say that any Eiffel system S is a set of classes {C1,C2…Cn} such that Cq<Cp if q<p. In practice class C1 will allways be class ANY but this is not of importance here.

The function:

  • τ:TYPE→(NAME→FEATURE)

Yields the features declared in a given class.

  • η:TYPE→(ℕ→(NAME→NAME))

Yields the renamings of the different parent parts by a class:

η(A)(1) gives the renamings of the first parent part of class A.

We will use the shortcut ηn,i for η(Cn)(i)

  • α:TYPE→(ℕ→TYPE)

Gives the class from which a given parent part of a class inherits:

α(A)(1) Gives the base class of the first parent part of class A.

We will use the shortcut αn,i for α(Cn)(i)

  • σ:TYPE→POW(NAME)

Gives all the selected feature names of a given class.

The naming function

In this section the naming function of a system is shown:

Its structure

βS:(TYPE×TYPE)→(NAME→NAME)

As a helper function we also need function:

βS′:(TYPE×TYPE)→(NAME↔NAME)

We will give a recursive definition of βS. Meaning that we will give β{C1,…Cm} given that we already now β{C1,…Cm−1}

This is valid since:

β{C1}⊆β{C1,C2}⊆…βS


β{C1}(C1↦C1)=id(dom(τ{C1}(C1)))

We introduce the shurtcut Sm to denote the system with classes {C1…Cm}

βSm(Cp↦Cq)=βSm−1(Cp↦Cq) for p<m∧q<m

βSm(Cm↦Cm)=id(dom(τ{Cm}(Cm)))∪⋃i=1..∞βSm−1(αm,i,αm,i)≪ηm,i

βSm′(Cq↦Cp)=⋃i=1..∞βSm−1(Cq↦αp,i);(id(ran(βSm−1(Cq↦αp,i)))≪ηm,i)

βSm(Cq↦Cp)=βSm′(Cq↦Cp)≪(βSm′(Cq↦Cp)▹σ(Cq))