home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18290 < prev    next >
Encoding:
Text File  |  1992-12-22  |  2.3 KB  |  53 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: "type safety" deemed essential
  5. Message-ID: <1992Dec22.000032.22654@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1992Dec14.212143.15591@leland.Stanford.EDU> <rmartin.724430168@thor> <448@genie.UUCP>
  10. Date: Tue, 22 Dec 1992 00:00:32 GMT
  11. Lines: 40
  12.  
  13. In article <448@genie.UUCP> roger@genie.UUCP (Roger H. Scott) writes:
  14. >In article <rmartin.724430168@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
  15.  
  16. >>For any significant industrial application, I think strong typing is
  17. >>utterly essential.  It is just too easy to create horrible run time
  18. >>errors without type safety.  
  19. >
  20. >This sounds like theory rather than practice speaking.  Let's hear from the
  21. >(net) C++ user community: who has written a non-trivial commercial C++ 
  22. >application *without* making significant use of either type casting [(T *)]
  23. >or run-time type checking [Bar *bar_p = foo_p->asBar();]?  
  24.  
  25.     I have. I hardly EVER use casts. I have used discriminated
  26. unions for heterogeneity, and this idiom is indeed insecure,
  27. which is why I'm working on a proposal to fix this.
  28.  
  29. >I maintain that
  30. >C++ makes it *very* difficult to do without at least one or the other of these
  31. >(Eiffel-style "anchored" virtual function return types would go a long way to
  32. >alleviate this).  
  33.  
  34.     On the contrary, this would open a gaping hole in the type system.
  35. They also only apply to special (though common) cases where multiple
  36. dispatch is required. Then you have to choose between safety and
  37. extensibility, you cant have both (the run-time checks ar required)
  38.  
  39. >I'm hoping that templates will help in this regard, but they
  40. >haven't been available long enough to judge.
  41.  
  42.     Its next to impossible to write generic container classes
  43. without using templates or casting. So use templates.
  44.  
  45.     It is sometimes necessary to do dynamic downcasting,
  46. but such uses are usually not required in ordinary programs.
  47.  
  48. -- 
  49. ;----------------------------------------------------------------------
  50.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  51.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  52. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  53.