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

  1. Path: sparky!uunet!igor!thor!rmartin
  2. From: rmartin@thor.Rational.COM (Bob Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Language extensions for run-time type identification
  5. Message-ID: <rmartin.711827497@thor>
  6. Date: 22 Jul 92 17:51:37 GMT
  7. References: <EY048MK@netmbx.netmbx.de> <TMB.92Jul20182052@arolla.idiap.ch>
  8. Sender: news@Rational.COM
  9. Lines: 39
  10.  
  11. tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
  12.  
  13. >As I understand it (I haven't read the proposal), there will
  14. >apparently be a half-hearted attempt at adding runtime type tags to
  15. >some user-defined classes. From the descriptions of the proposal that
  16. >I have heard, that will not be sufficient to make the C++ language
  17. >safe (in the sense of eliminating most sources of "undefined
  18. >behavior"). In fact, at best, it will encourage a careless programming
  19. >style that relies on runtime type tests rather than inheritance and
  20. >virtual functions.
  21.  
  22. Ack!  Such cynisism; and from someone who hasn't even read the
  23. proposal yet!  First read the proposal, *then* you can be cynical.
  24.  
  25. Actually, the RTTI proposal sounds pretty good to me. (I have read
  26. it.)  It is a trade-off, as is nearly every feature of C++; but it is
  27. a well thought out one.  It certainly makes the language safer, since
  28. casts which had been legal and unchecked will now become dynamically
  29. checked.  Will it encourage careless programming?  Please!  Careless
  30. programing is perpetrated by careless programmers.  Careless
  31. programmers are not thwarted in their intentions by the language they
  32. use.
  33.  
  34. Can RTTI be misused?  Certainly!  So can integers:
  35.         for (i=0; i<1e99; i++) ;
  36.  
  37. Does RTTI improve the language?  Yes, emphatically.  Specifically in
  38. the area of identifying objects which come out of heterogenous
  39. containers.  Some have expressed the opinion that RTTI should not be
  40. used in this way since the objects in heterogenous containers should
  41. be accessed only by their known interface.  This is usually correct.
  42. But there are occasions where DOWNCASTING such objects is useful.
  43.  
  44.  
  45. --
  46. +---Robert C. Martin---+-RRR---CCC-M-----M-| R.C.M. Consulting         |
  47. | rmartin@rational.com |-R--R-C----M-M-M-M-| C++/C/Unix Engineering    |
  48. |     (Uncle Bob.)     |-RRR--C----M--M--M-| OOA/OOD/OOP Training      |
  49. +----------------------+-R--R--CCC-M-----M-| Product Design & Devel.   |
  50.