home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.eiffel
- Path: sparky!uunet!psinntp!merlin.hgc.edu!jcm
- From: jcm@hgc.edu (James McKim)
- Subject: Re: select (Eiffel 3.0)
- Message-ID: <1992Sep8.134316.3797@merlin.hgc.edu>
- Sender: usenet@merlin.hgc.edu (Action News Central)
- Organization: The Hartford Graduate Center
- References: <MATTHEW.92Sep7142939@matthew.ntl02.decnet.nokia.fi>
- Date: Tue, 8 Sep 1992 13:43:16 GMT
- Lines: 83
-
- In article <MATTHEW.92Sep7142939@matthew.ntl02.decnet.nokia.fi> matthew@ntl02.decnet.nokia.fi (Matthew Faupel) writes:
- >The select statement in Eiffel 3.0 is intended to choose the dominant
- >version of alternative features inherited from a common base class, hence:
- >
- >class A
- > feature x: INTEGER is
- > Result := 1
- > end
- >end
- >
- >class B
- > inherit A rename x as Bx, redefine Bx
- > feature Bx: INTEGER is
- > Result := 2
- > end
- >end
- >
- >class C
- > inherit A rename x as Cx, redefine Cx
- > feature Cx: INTEGER is
- > Result := 3
- > end
- >end
- >
- >class D
- > inherit B, C
- > select Bx
- >end
- >
- >... defines Bx to be the dominant definition of feature x of A if a D object
- >is ever referenced by a type A reference. Apologies if I have the syntax
- >slightly wrong, I don't have the manual in front of me.
- >
- >Given the above definitions, I think the following are obvious:
- >
- >anA: A; aB: B; aC: C; aD: D;
- >!!aD;
- >aD.Bx; -- returns 2
- >aD.Cx; -- returns 3
- >anA := aD;
- >anA.x; -- returns 2
- >aB := aD;
- >aB.Bx; -- returns 2
- >anA := aB;
- >anA.x; -- returns 2
- >
- >Now come the tricky ones:
-
- >
- >aC := aD;
- >aC.Cx; -- returns 2 or 3?
-
- Should act just like aD.Cx above and return 3.
-
- >anA := aC;
- >anA.x; -- returns 2 or 3?
-
- I'm assuming this assignment _follows_ the previous one as opposed to being
- an independent example. In that case anA's runtime type is D, the select
- clause comes into play and the result is 2.
-
- At least that's my vote. :-)
-
- >
- >Can anyone help?
- >
- >Thanks,
- >
- >
- >Matthew
- >--
- >---* Amnesiac the Wizard *------------------* matthew@uk.tele.nokia.fi *---
- > Opinions expressed here are not those of my company. | NB. ntl02 is EN
- > They're not even my own; I plagiarised the lot of them! | TEE EL ZERO TWO
- >---* matthew@ntl02.decnet.nokia.fi *------------------* Matthew Faupel *---
-
-
- -- Jim
- --
-
- *------------------------------------------------------------------------------*
- Jim McKim (203)-548-2458 In exactly 3.2 seconds it will be a few
- Internet: jcm@hgc.edu minutes to 5:00.
-