home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / eiffel / 1297 next >
Encoding:
Text File  |  1992-11-07  |  1.5 KB  |  66 lines

  1. Path: sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!network.ucsd.edu!ucsbcsl!ucsb.edu
  2. From: ambuj@ucsb.edu (Singh)
  3. Newsgroups: comp.lang.eiffel
  4. Subject: repeated inheritance and renaming
  5. Message-ID: <6546@ucsbcsl.ucsb.edu>
  6. Date: 6 Nov 92 00:47:37 GMT
  7. Sender: root@ucsbcsl.ucsb.edu
  8. Organization: University of California, Santa Barbara
  9. Lines: 55
  10.  
  11.  
  12. I have the following question regarding repeated 
  13. inheritance and renaming in Eiffel.
  14.  
  15. Suppose I have the following classes:
  16.  
  17.             class R
  18.             feature
  19.                 x:integer;
  20.                 f is do
  21.                     x := x+1;
  22.                 end;
  23.             end
  24.  
  25.  
  26. class A            class B            class C
  27. inherit            inherit            inherit 
  28.   R redefine f;          R rename x as xB      R
  29. feature            end            end
  30.   f is do
  31.     x := x + 2;
  32.   end;
  33. end
  34.  
  35.             class S
  36.             inherit 
  37.                 A rename f as fA;
  38.                 B rename f as fB;
  39.                 C;
  40.             feature
  41.                 Create is
  42.                     do
  43.                         fB;
  44.                         io.putint(xB); io.new_line;
  45.                     end;
  46.             end
  47.  
  48. Assume that class S is the ``root'' class of the system.
  49. Upon activation of S.create,
  50. I would have expected procedure fB to update xB and
  51. the subsequent print statement to print 1.
  52. However, it seems that fB updates x instead of xB
  53. and 0 is the value printed.
  54. I also find that if S does not inherit from A then the
  55. expected happens and 1 gets printed.
  56. What am I missing?  Is this a problem with the installation
  57. of Eiffel?
  58.  
  59. Thanks.
  60.  
  61. Ambuj Singh
  62. Dept. of Computer Science
  63. University of California
  64. Santa Barbara, CA 93106
  65. ambuj@cs.ucsb.edu
  66.