home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / modula3 / 843 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  2.9 KB

  1. Xref: sparky comp.lang.modula3:843 comp.lang.misc:2685 comp.lang.c++:11262
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!pacbell.com!network.ucsd.edu!lyapunov.ucsd.edu!mbk
  3. From: mbk@lyapunov.ucsd.edu (Matt Kennel)
  4. Newsgroups: comp.lang.modula3,comp.lang.misc,comp.lang.c++
  5. Subject: Re: Sather's Multiple Inheritance
  6. Date: 21 Jul 1992 20:04:41 GMT
  7. Organization: Institute For Nonlinear Science, UCSD
  8. Lines: 92
  9. Message-ID: <14hqkpINN3h6@network.ucsd.edu>
  10. References: <ARI.HUTTUNEN.92Jul20112548@wonderwoman.hut.fi>
  11. NNTP-Posting-Host: lyapunov.ucsd.edu
  12. X-Newsreader: Tin 1.1 PL3
  13.  
  14. Ari.Huttunen@hut.fi (Ari Juhani Huttunen) writes:
  15. : In article <147qlkINNft3@network.ucsd.edu> mbk@lyapunov.ucsd.edu (Matt Kennel) writes:
  16. : ! Now what if both PARENT_CLASS_ONE and PARENT_CLASS_TWO
  17. : ! have two features, say integer variables "count":
  18. : ! Then you can use "alias new_name old_name":
  19. : ! ===========
  20. : ! class CHILD is
  21. : !     PARENT_CLASS_ONE;    --- That inherits it
  22. : !     alias count_one count;    --- rename "count" from P_C_O
  23. : !     PARENT_CLASS_TWO;    --- That inherits another
  24. : !     alias count_two count;    --- Rename that one as well
  25. : !     count : INT;        --- A third "count" different from the
  26. : !                 --- other two.
  27. : ! end;
  28. : ! ============
  29. : ! I don't know if this solution is perfect for all circumstances, but it
  30. : ! appears to a layman to cover a whole lot, and it's very easy to understand.
  31. : You still have the problem that CHILD, PARENT_CLASS_ONE and PARENT_CLASS_TWO
  32. : refer to the same 'count' each, unless you re-rewrite the functions in
  33. : the parent classes. (In some cases this would be desirable, in others it
  34. : would not.)
  35. : The problem would be solved, if this were possible: 'rename count_two count'.
  36.  
  37. I think there's a bug in the compiler, actually.  As you were, I wasn't able
  38. to override an integer feature (storage) with a procedure, but I was
  39. able to override that same integer feature with a feature of different type.
  40. ============================
  41. class FATHER is
  42.  
  43.     private xyz:INT;
  44.  
  45.         foobar is
  46.                 xyz := 123;
  47.         end; -- foobar
  48.  
  49. end; -- FATHER
  50.  
  51. class CHILDBAD is
  52.  
  53.         FATHER;
  54.         alias father_xyz xyz;
  55.  
  56.         xyz:DOUBLE is
  57.                 res := 1.0;
  58.         end; -- xyz
  59.  
  60. end; -- CHILDBAD
  61.  
  62. class CHILDGOOD is
  63.  
  64.         FATHER;
  65.         alias father_xyz xyz;
  66.  
  67.         xyz:DOUBLE;
  68.  
  69. end; -- CHILDGOOD
  70.  
  71.  
  72. class TEST is
  73.     main is
  74.         a:FATHER;
  75.         a.foobar;
  76.  
  77.         b:CHILDGOOD;
  78.         b.foobar;
  79.  
  80. --        c:CHILDBAD;
  81. --        c.foobar;
  82. --  Compiler gives an error if you uncomment these lines! ???
  83. --
  84.     end;
  85.  
  86. end;
  87.  
  88. ===================================
  89.  
  90. : --
  91. : ...............................................................................
  92. : Ari Huttunen                               They say the sky high above
  93. : 90-7285944                                   is Caribbean blue...  (Enya)
  94.  
  95. --
  96. -Matt Kennel          mbk@inls1.ucsd.edu
  97. -Institute for Nonlinear Science, University of California, San Diego
  98.