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

  1. Newsgroups: comp.lang.eiffel
  2. Path: sparky!uunet!psinntp!merlin.hgc.edu!jcm
  3. From: jcm@hgc.edu (James McKim)
  4. Subject: Re: select (Eiffel 3.0)
  5. Message-ID: <1992Sep8.134316.3797@merlin.hgc.edu>
  6. Sender: usenet@merlin.hgc.edu (Action News Central)
  7. Organization: The Hartford Graduate Center
  8. References: <MATTHEW.92Sep7142939@matthew.ntl02.decnet.nokia.fi>
  9. Date: Tue, 8 Sep 1992 13:43:16 GMT
  10. Lines: 83
  11.  
  12. In article <MATTHEW.92Sep7142939@matthew.ntl02.decnet.nokia.fi> matthew@ntl02.decnet.nokia.fi (Matthew Faupel) writes:
  13. >The select statement in Eiffel 3.0 is intended to choose the dominant
  14. >version of alternative features inherited from a common base class, hence:
  15. >
  16. >class A                     
  17. >   feature x: INTEGER is    
  18. >      Result := 1           
  19. >   end                      
  20. >end                        
  21. >                           
  22. >class B
  23. >   inherit A rename x as Bx, redefine Bx
  24. >   feature Bx: INTEGER is
  25. >      Result := 2
  26. >   end
  27. >end
  28. >
  29. >class C
  30. >   inherit A rename x as Cx, redefine Cx
  31. >   feature Cx: INTEGER is
  32. >      Result := 3
  33. >   end
  34. >end
  35. >
  36. >class D
  37. >   inherit B, C
  38. >   select Bx
  39. >end
  40. >
  41. >... defines Bx to be the dominant definition of feature x of A if a D object
  42. >is ever referenced by a type A reference.  Apologies if I have the syntax
  43. >slightly wrong, I don't have the manual in front of me.
  44. >
  45. >Given the above definitions, I think the following are obvious:
  46. >
  47. >anA: A; aB: B; aC: C; aD: D;
  48. >!!aD;
  49. >aD.Bx; -- returns 2
  50. >aD.Cx; -- returns 3
  51. >anA := aD;
  52. >anA.x; -- returns 2
  53. >aB := aD;
  54. >aB.Bx; -- returns 2
  55. >anA := aB;
  56. >anA.x; -- returns 2
  57. >
  58. >Now come the tricky ones:
  59.  
  60. >
  61. >aC := aD;
  62. >aC.Cx; -- returns 2 or 3?
  63.  
  64. Should act just like aD.Cx above and return 3.
  65.  
  66. >anA := aC;
  67. >anA.x; -- returns 2 or 3?
  68.  
  69. I'm assuming this assignment _follows_ the previous one as opposed to being
  70. an independent example. In that case anA's runtime type is D, the select
  71. clause comes into play and the result is 2.
  72.  
  73. At least that's my vote. :-)
  74.  
  75. >
  76. >Can anyone help?
  77. >
  78. >Thanks,
  79. >
  80. >
  81. >Matthew
  82. >--
  83. >---* Amnesiac the Wizard *------------------* matthew@uk.tele.nokia.fi *---
  84. > Opinions expressed here are not those of my company.    | NB. ntl02 is EN
  85. > They're not even my own; I plagiarised the lot of them! | TEE EL ZERO TWO
  86. >---* matthew@ntl02.decnet.nokia.fi *------------------* Matthew Faupel *---
  87.  
  88.  
  89. -- Jim
  90. -- 
  91.  
  92. *------------------------------------------------------------------------------*
  93. Jim McKim  (203)-548-2458     In exactly 3.2 seconds it will be a few 
  94. Internet:  jcm@hgc.edu   minutes to 5:00.
  95.