home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / eiffel / 1115 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.8 KB  |  75 lines

  1. Newsgroups: comp.lang.eiffel
  2. Path: sparky!uunet!mcsun!news.funet.fi!funic!nokia.fi!newshost!matthew
  3. From: matthew@ntl02.decnet.nokia.fi (Matthew Faupel)
  4. Subject: select (Eiffel 3.0)
  5. Message-ID: <MATTHEW.92Sep7142939@matthew.ntl02.decnet.nokia.fi>
  6. Lines: 63
  7. Sender: usenet@noknic.nokia.fi (USENET at noknic)
  8. Nntp-Posting-Host: matthew.uk.tele.nokia.fi
  9. Organization: Nokia Telecommunications, Cambridge, UK
  10. Date: Mon, 7 Sep 1992 14:30:21 GMT
  11.  
  12. The select statement in Eiffel 3.0 is intended to choose the dominant
  13. version of alternative features inherited from a common base class, hence:
  14.  
  15. class A                     
  16.    feature x: INTEGER is    
  17.       Result := 1           
  18.    end                      
  19. end                        
  20.                            
  21. class B
  22.    inherit A rename x as Bx, redefine Bx
  23.    feature Bx: INTEGER is
  24.       Result := 2
  25.    end
  26. end
  27.  
  28. class C
  29.    inherit A rename x as Cx, redefine Cx
  30.    feature Cx: INTEGER is
  31.       Result := 3
  32.    end
  33. end
  34.  
  35. class D
  36.    inherit B, C
  37.    select Bx
  38. end
  39.  
  40. ... defines Bx to be the dominant definition of feature x of A if a D object
  41. is ever referenced by a type A reference.  Apologies if I have the syntax
  42. slightly wrong, I don't have the manual in front of me.
  43.  
  44. Given the above definitions, I think the following are obvious:
  45.  
  46. anA: A; aB: B; aC: C; aD: D;
  47. !!aD;
  48. aD.Bx; -- returns 2
  49. aD.Cx; -- returns 3
  50. anA := aD;
  51. anA.x; -- returns 2
  52. aB := aD;
  53. aB.Bx; -- returns 2
  54. anA := aB;
  55. anA.x; -- returns 2
  56.  
  57. Now come the tricky ones:
  58.  
  59. aC := aD;
  60. aC.Cx; -- returns 2 or 3?
  61. anA := aC;
  62. anA.x; -- returns 2 or 3?
  63.  
  64. Can anyone help?
  65.  
  66. Thanks,
  67.  
  68.  
  69. Matthew
  70. --
  71. ---* Amnesiac the Wizard *------------------* matthew@uk.tele.nokia.fi *---
  72.  Opinions expressed here are not those of my company.    | NB. ntl02 is EN
  73.  They're not even my own; I plagiarised the lot of them! | TEE EL ZERO TWO
  74. ---* matthew@ntl02.decnet.nokia.fi *------------------* Matthew Faupel *---
  75.