home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.eiffel
- Path: sparky!uunet!mcsun!news.funet.fi!funic!nokia.fi!newshost!matthew
- From: matthew@ntl02.decnet.nokia.fi (Matthew Faupel)
- Subject: select (Eiffel 3.0)
- Message-ID: <MATTHEW.92Sep7142939@matthew.ntl02.decnet.nokia.fi>
- Lines: 63
- Sender: usenet@noknic.nokia.fi (USENET at noknic)
- Nntp-Posting-Host: matthew.uk.tele.nokia.fi
- Organization: Nokia Telecommunications, Cambridge, UK
- Date: Mon, 7 Sep 1992 14:30:21 GMT
-
- 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?
- anA := aC;
- anA.x; -- returns 2 or 3?
-
- 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 *---
-