home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13558 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.4 KB  |  58 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!netcon!intime.intime.COM!scottm
  3. From: scottm@intime.intime.COM (Scott Michel)
  4. Subject: Re: zero-length datatype
  5. Organization: IntelliMED Corporation, Santa Monica, CA
  6. Distribution: comp
  7. Date: Sat, 12 Sep 1992 00:50:52 GMT
  8. Message-ID: <BuFx0t.IFA@intime.intime.COM>
  9. References: <23654@alice.att.com> <1992Sep11.185505.17536@cadsun.corp.mot.com>
  10. Lines: 46
  11.  
  12. In article <1992Sep11.185505.17536@cadsun.corp.mot.com> shang@corp.mot.com writes:
  13. >In article <23654@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
  14. >> In article <1992Sep10.181836.9929@cadsun.corp.mot.com> shang@corp.mot.com  
  15. >writes:
  16. [ ... truncated ... ]
  17. >
  18. >But I don't see the reason why we can't have zero-size objects. Don't 
  19. >say that the standard explicitly says that. I want to know why it says 
  20. >that. So far, I haven't heard any convincing argument.
  21.  
  22. What it seems that people are getting at is the fundamental issue of
  23. a class that consists only of methods, devoid of attributes. Is such
  24. a class useful? IMNSHO, it is if you are abstracting a library object
  25. which has no state information but passes control solely to active
  26. methods. Whether this is a good idea conceptually or not is subject to
  27. other threads. It is nonetheless a valid example of where you might
  28. have a zero length class:
  29.  
  30.     class Gateway {
  31.     public:
  32.       void gate_entry_1(int arg1, const char *arg2);
  33.       int gate_entry_2(const char *arg);
  34.     }
  35.  
  36. However, it's clear that the reason why C++ doesn't allow one to have
  37. a zero length object is that all instances of objects must be unique.
  38. This is a Reasonable Thing, otherwise you'd end up with real confusion
  39. in the language as to whether or not an object is really a stand-in or
  40. alias for another, and whether or not the object exists in the first
  41. place. Is one zero-length object itself or a meta object for another?
  42. According to Aristotle's theory of classes (and his philosophy as a whole)
  43. you'd force yourself into a situation where something can be itself and
  44. not itself similtaneously. The only place where an object may have a
  45. useful zero length is in a base class, and it would only be logical that
  46. it is illegal to use a zero length object in any other sense.
  47.  
  48. The discussion regarding problems of promoting void to a real datatype
  49. a non sequitor: How can a void thing have substance? (e.g being itself
  50. and not itself problem)
  51.  
  52. >
  53. >David Shang
  54.  
  55. There's my $0.02. 'Nuf said yet?
  56.  
  57. -scottm
  58.