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

  1. Newsgroups: comp.lang.eiffel
  2. Path: sparky!uunet!mcsun!news.funet.fi!ajk.tele.fi!funic!nokia.fi!newshost!matthew
  3. From: matthew@ntl02.decnet.nokia.fi (Matthew Faupel)
  4. Subject: Re: select (Eiffel 3.0)
  5. In-Reply-To: matthew@ntl02.decnet.nokia.fi's message of Tue, 8 Sep 1992 16:08:26 GMT
  6. Message-ID: <MATTHEW.92Sep8162544@matthew.ntl02.decnet.nokia.fi>
  7. Lines: 60
  8. Sender: usenet@noknic.nokia.fi (USENET at noknic)
  9. Nntp-Posting-Host: matthew.uk.tele.nokia.fi
  10. Organization: Nokia Telecommunications, Cambridge, UK
  11. References: <GEOFF.92Sep8101023@wodehouse.flash.bellcore.com>
  12.     <MATTHEW.92Sep8160738@matthew.ntl02.decnet.nokia.fi>
  13. Date: Tue, 8 Sep 1992 16:26:32 GMT
  14.  
  15. GC: Geoffrey Clemm in article <GEOFF.92Sep8101023@wodehouse.flash.bellcore.com>
  16. MF: Me in article <MATTHEW.92Sep7142939@matthew.ntl02.decnet.nokia.fi>
  17.  
  18. MF:    class A                     
  19. MF:       feature x: INTEGER is    
  20. MF:      Result := 1 end end                        
  21. MF:    class B inherit A rename x as Bx, redefine Bx
  22. MF:       feature Bx: INTEGER is
  23. MF:      Result := 2 end end
  24. MF:    class C inherit A rename x as Cx, redefine Cx
  25. MF:       feature Cx: INTEGER is
  26. MF:      Result := 3 end end
  27. MF:    class D inherit B, C
  28. MF:       select Bx end
  29. MF:    ...
  30. MF:    Now come the tricky ones:
  31.  
  32. MF:    aC := aD;
  33. MF:    aC.Cx; -- returns 2 or 3?
  34. MF:    anA := aC;
  35. MF:    anA.x; -- returns 2 or 3?
  36.  
  37. MF:    Can anyone help?
  38.  
  39. GC: Cx has never been redefined or renamed, so it will always return 3.  
  40.  
  41. GC: If the dynamic type of anA is aC, then anA.x must be the Cx that redefines x.
  42. GC: The select statement in D (or for that matter, the very existence of D) is
  43. GC: irrelevant to this decision.
  44.  
  45. GC: I'm not sure why these are tricky.  How could the answers be anything else ?
  46.  
  47. Ah... I seem to have phrased the question rather badly, because this is the
  48. second reply I've had which misinterpreted it.  What I meant was:
  49.  
  50. !!aD; aC := aD; anA := aC; anA.x; -- a
  51.                 anA := aD; anA.x; -- b
  52.  
  53. Here we have two invocations of the same feature name on the same dynamic
  54. object via the same static reference, do they produce different results
  55. (i.e. does a return 3 but b, 2) or the same (both returning 2 because
  56. feature Bx was selected as the dominant implementation of x when referring
  57. to an object of type D via a reference of type A)?
  58.  
  59. In other words, does select always operate or only when the assignment path
  60. doesn't make it clear which version of the feature should be used?
  61.  
  62. I've now had an answer from someone in ISE, and the answer is that they both
  63. return 2; the assignment path makes no difference.  Next question, is this
  64. really the desired behaviour?  Answers on a postcard please :-)
  65.  
  66. Cheers,
  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.