home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11652 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.0 KB  |  60 lines

  1. Xref: sparky comp.lang.c++:11652 comp.std.c++:968
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!tmb
  3. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  4. Newsgroups: comp.lang.c++,comp.std.c++
  5. Subject: mating dogs and cats (Re: run-time type checking)
  6. Message-ID: <TMB.92Jul28121957@arolla.idiap.ch>
  7. Date: 28 Jul 92 16:19:57 GMT
  8. References: <1992Jul21.162659.25474@ucc.su.OZ.AU>
  9.     <1992Jul22.022218.1115@cadsun.corp.mot.com>
  10.     <1992Jul23.154254.5306@ucc.su.OZ.AU>
  11. Sender: news@ai.mit.edu
  12. Reply-To: tmb@idiap.ch
  13. Followup-To: comp.lang.c++
  14. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  15.     Perceptive)
  16. Lines: 41
  17. In-reply-to: maxtal@extro.ucc.su.OZ.AU's message of 23 Jul 92 15:42:54 GMT
  18.  
  19. In article <1992Jul23.154254.5306@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  20.  
  21.    The problem is why you proposed 'thisclass' and is a real problem.
  22.    It is a problem for which RTTI is the wrong solution,
  23.    but never-the-less is the best we will get for a while.
  24.    We really need multiple dispatch.
  25.  
  26.    class Animal {
  27.        int mate(Animal&);
  28.    };
  29.    class Dog : Animal {
  30.        int mate (Animal&);
  31.    };
  32.  
  33.    We REALLY want Dog::mate(Dog&), but we cant have it.
  34.  
  35. I don't see the problem.
  36.  
  37. class Animal {
  38.     virtual int mate(Animal &) = 0;
  39.     virtual int mate_dog(Animal &other) {error("not a dog");}
  40.     virtual int mate_cat(Animal &other) {error("not a cat");}
  41. };
  42.  
  43. class Dog {
  44.     int mate(Animal &other) {return mate_dog(other);}
  45.     int mate_dog(Animal &other) { ... do it the way dogs do it ... }
  46. };
  47.  
  48.    This is a flaw in Object Oriented Programming IMHO.
  49.    The solution requires multimethods which are inherently
  50.    functional.
  51.  
  52. I don't see that this particular thing is a flaw with Object Oriented
  53. programming. Nor do you need RTTI to solve this problem.
  54.  
  55. I assume that by "functional" you mean "CLOS-style methods". I agree
  56. that they are more convenient and easier to maintain, but at least in
  57. this respect, they don't give you more functionality.
  58.  
  59.                     Thomas.
  60.