home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13605 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  2.5 KB

  1. Path: sparky!uunet!olivea!spool.mu.edu!sol.ctr.columbia.edu!usc!snorkelwacker.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: zero-length datatype
  5. Message-ID: <TMB.92Sep14145655@arolla.idiap.ch>
  6. Date: 14 Sep 92 18:56:55 GMT
  7. References: <23654@alice.att.com> <1992Sep11.185505.17536@cadsun.corp.mot.com>
  8.     <23659@alice.att.com> <TMB.92Sep12212903@arolla.idiap.ch>
  9.     <23661@alice.att.com>
  10. Sender: news@ai.mit.edu
  11. Reply-To: tmb@idiap.ch
  12. Distribution: comp
  13. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  14.     Perceptive)
  15. Lines: 39
  16. In-reply-to: ark@alice.att.com's message of 13 Sep 92 15:19:04 GMT
  17.  
  18. In article <23661@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
  19.  
  20. >In article <TMB.92Sep12212903@arolla.idiap.ch> tmb@idiap.ch writes:
  21.  
  22. >> Well, it might be good to remain compatible, in the sense that every
  23. >> object that has non-zero size in ISO C also have a non-zero size in
  24. >> C++. However, since there are no objects of type "void" (or of some
  25. >> other, newly introduced, distinguished type with zero size) in ISO C,
  26. >> there can't be any harm in letting objects of this new type have zero
  27. >> size: the behavior of existing code would not be affected.
  28. >
  29. >That is not quite true, especially in the presence of templates.
  30. >
  31. >I expect that there will be some committee members who will say
  32. >that they want to be able to assume that objects of any type at all
  33. >are nonzero in size and admitting a new empty type would violate
  34. >that assumption.  And indeed it might even affect old C code, if that
  35. >code uses a type that is macro-expanded into something not known until
  36. >the code is actually compiled.
  37.  
  38. I discussed this issue at great depth in a previous posting.
  39.  
  40. To summarize again:
  41.  
  42. Yes, it is obviously true that if you hand a "void" as an argument to
  43. a template function (or template macro) that was written with the
  44. assumption that there are no zero-length datatypes, that template
  45. function may not behave as expected. But that's true for any other new
  46. type or type-related construct that C++ adds: handing a new quad
  47. precision datatype to a numerical template function, for example,
  48. might cause non-termination.
  49.  
  50. Existing code can't legally hand "void" to an existing template
  51. function, hence it will not be affected by the feature. If you write
  52. new code that uses an old template function, then you better make sure
  53. that the types you use work for that template function; that's true
  54. for _any_ kind of type you might use, not just "void".
  55.  
  56.                     Thomas.
  57.