home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18778 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!uwm.edu!ogicse!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: "type safety" deemed essential
  5. Message-ID: <TMB.93Jan6220042@arolla.idiap.ch>
  6. Date: 7 Jan 93 06:00:42 GMT
  7. Article-I.D.: arolla.TMB.93Jan6220042
  8. References: <450@genie.UUCP> <725053473snx@trmphrst.demon.co.uk>
  9.     <726346306snx@trmphrst.demon.co.uk>
  10. Reply-To: tmb@idiap.ch
  11. Distribution: world
  12. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  13.     Perceptive)
  14. Lines: 22
  15. NNTP-Posting-Host: arolla.idiap.ch
  16. In-reply-to: nikki@trmphrst.demon.co.uk's message of Wed, 6 Jan 1993 11:51:46 +0000
  17.  
  18. In article <448@genie.UUCP> roger@genie.UUCP (Roger H. Scott) writes:
  19. > ... [W]ho has written a non-trivial commercial C++ 
  20. > application *without* making significant use of either type casting [(T *)]
  21. > or run-time type checking [Bar *bar_p = foo_p->asBar();]?  
  22.  
  23. In article <726346306snx@trmphrst.demon.co.uk> nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
  24. > [suggesting that some 31000 lines of code he has written without
  25. > using these features are "non-trivial"]
  26.  
  27. Unfortunately, C++ still lacks some kind of "tagged union type",
  28. "typesafe union type", or, if you are a Pascal fan, a "variant record
  29. with runtime type checking". Those kinds of datatypes are useful in
  30. many applications. A common example is that of a binary tree with
  31. different node and leaf types.
  32.  
  33. There are workarounds, but they either use a lot more memory (using a
  34. "struct" instead of a "union"), or they aren't type-safe (pointer
  35. casts or C-style unions). And with any such workaround in C/C++, you
  36. are missing out on useful compile time diagnostics and optimizations
  37. that would be possible if the feature was supported.
  38.  
  39.                     Thomas.
  40.