From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public X-Google-Thread: fac41,c52c30d32b866eae X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public From: Jacob Gore Subject: Re: Real OO Date: 1996/04/12 Message-ID: <4kmosp$mk0@Sahara.enmu.edu>#1/1 X-Deja-AN: 147215016 distribution: world references: organization: Eastern New Mexico University newsgroups: comp.lang.eiffel,comp.lang.ada,comp.object Date: 1996-04-12T00:00:00+00:00 List-Id: Don Harrison writes > I must confess to still being in the woods over whether: > > corresponding_parts_equal (other: like Current): BOOLEAN is ... > > means that, in a call x.corresponding_parts_equal (y): > > a) the STATIC type of y must conform to the STATIC type of x, or > b) the DYNAMIC type of y must conform to the DYNAMIC type of x > > ('conform to' meaning having the same (or more specific) type). Let me try to answer this question while avoiding this terminology for a while. Suppose the declaration of class PPP contains the declarations x: AAA; y: like x; The first line means "x can refer to an object in class AAA, or an object in any subclass of AA". No confusion there, right? Simple o-o stuff. The second line means "the rules that are applicable to y in this class are the same as the rules that are applicable to x in this class." The words to note are "in this class". They refer to "the flat form" of the class: all the code introduced in this class, plus all the code that is inherited but not redefined. That definition is simple, and includes the answer to your question. However, if you are trying to decide whether that means "of same type as the variable x" ("static type") vs. "in the same class as the object to which x refers" ("dynamic type"), please observe that it does not mean either. Consider an example. Suppose class QQQ inherits from PPP. If it redefines x as x: BBB; (which is legal as long as BBB is a descendant of AAA), then y, as an object in class QQQ sees it, may refer only to an object in class BBB or a subclass of BBB. On the other hand, if QQQ just inherits x (so it is still "x: AAA"), then y may refer to an object in class AAA or in a subclass of AAA. The same rules apply to y as to x -- as an object in class QQQ sees y and x. So what does that mean for the declaration y: like Current (which was the original question)? Conceptually, Current is always redefined to the most specific type. In class AAA, Current is of type AAA, in class BBB, it is of type BBB, etc. So "y: like Current" means that y can only be an object in the same class as the object that is executing the given code. So in the case of "like Current", you do get the "dynamic type". But only because the "static type" of Current is always the same as its "dynamic type." In general, "like x" means "the `static type' of x, from the point of view of the object referred to by Current." Hope this gets you through the woods :-) Jacob --- Jacob Gore, Eastern NM U. Jacob.Gore@ENMU.Edu | Jacob@ToolCASE.Com