Note that in the above de nition we have introduced

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: nds on . The relation ( is actually a partial order. It should be clear that we do not allow, in particular, the is-a hierarchy to depend on inheritability or properties of objects. This restriction helps make the is-a hierarchy static and keep the inheritability of properties deterministic. On the other hand, this still allows a large class of meaningful programs. 3.3.2 Informal Semantics of Inheritance The objects in our programs are described by a set of d-clauses and a matching set of s-clauses. Here, s-clauses de ne method signature and d-clauses de ne method behavior. Objects also inherit and reuse these descriptions (of structures and behaviors) with other objects that are de ned as their subclasses or instances, and they are subject to possible overriding by local de nitions. Consequently, the state of an object depends on the structure of the object hierarchy de ned using the is-a de nitions. In our conceptual model, we identify two types of p-clauses { local and inherited clauses. Intuitively, a p-clause is local to an object o, if it is de ned in o. On the other hand a p-clause de ning a method (data or signature) is inherited in o from q, if o does not de ne a similar p-clause and q is an ancestor of o such that q de nes the p-clause, and there is no other ancestor of o from which such a p-clause is inheritable by o. The following de nitions make these notions precise: De nition 3.2 (Locality) Let cl be a p-clause such that its descriptor is p, and 7! r 1 ]q1 : : : r n ]q n are all the is-a atoms4 in its body. Then cl is local to every object p 2 such that ri]qi holds for 1 i n. That is, p mk ] r1]q1 : : : rn]qn holds. The notion of inherited clauses depends on the notion of inheritability of p-clauses, de ned next. De nition 3.3 (Inheritability) Let S be a set of (ground) id-, l-, w-, and is-a atoms, mk be a method denotation, and o be an object. Then the inheritability of 7! In this de nition and in the sequel of the paper ] stands for either \:" or \::" in places where the distinction between the two is unimportant. 4 40 mk in the object o is de 8 > > > > > > > > >p > < k o) = r(S m > > > > > > > > > > :o 7! 7! 7! ned by the context function r as follows: if o mk ] 62 S and 9q such that o]q 2 S r(S mk q) = p, p mk ] 2 S and (8r such that o]r 2 S one of the following holds. 7! 7! 7! r(S mk r) = r, and r mk ] 62 S , or 7! 7! r(S mk r) = p, or o mk < r] 2 S , or r mk > o] 2 S .)] 7! 7! 7! in all other cases. 7! 7! 2 The operator r works as follows. Let o be any object and mk any method denotation. Then r(S mk o) = p only if o]p and p mk ], for some object p. Suppose o does not have its own de nition of method mk , as indicated by the absence of an atom o mk ] in S . Also suppose for some superclass p of o (i.e., o]p 2 S ), p mk ] 2 S . Then r(S mk o) = p, provided o has an immediate superclass q (which is possibly p) which inherits mk from p, and for every other immediate superclass r of o satis es one of the conditions: (i) r inherits mk from p (same source), (ii) r does not have a local de nition of mk (r mk ] 62 S ), neither does it inherit from any of its superclasses as indicated by r(S mk r) = r, or nally (iii) either o inhibits mk from r, or r blocks mk for o. In all other cases, r(S mk o) = o, indicating either o has a local de nition of mk and overrides all other de nitions of mk , or it cannot legitimately inherit mk from any of its superclasses, if at all they exist and de ne such a method. It is possible to show that r is a total function. 7! 7! 7! 7! 7! 7! 7! 7! 7! 7! 7! 7! 7! 7! 7! denotation. Let S be a set of ground is-a, l-, w- and id-atoms that are entailed by 5. Then cl is inheritable in an object q if r(S mk q) = o. The inherited clause cl in q is obtained by replacing every occurrence of o in cl by q, i.e., cl (A G) o= ], =q where o= ] denotes the replacement of the term o by q. =q 2 0 7! 0 De nition 3.4 (Inherited Clauses) Let P = h i be a program, cl A G 2 be a p-clause local to an object o, and let meth(A) = mk be a method 7! For our language, this set is always nite and entailment for this part is in the classical sense, as will be seen in Section 3.5. This set can be determined using classical proof theory or xpoint theory. We present the notion of inheritance here rather than in a later section, to give an intuitive feel for the semantics of inheritance, in advance. 5 41 We remark that context switch captured by the term replacement of the form % = fo==qg should not be confused with the usual substitutions (e.g., = fX=pg) where only variables are replaced by terms. We next illustrate with couple of examples our notion of behavioral inheritance (for code reuse) as well as indicate how the various notions developed above play a role in shaping the semantics of inheritance in ORLog. troduced earlier in Chapter 2) in Figure 4. We use this example to intuitively understand the underlying meaning of ORLog program...
View Full Document

This document was uploaded on 01/10/2011.

Ask a homework question - tutors are online