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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!convex!news.utdallas.edu!corpgate!bnrgate!bcrka451!bcrki65!sjm
  3. From: sjm@bcrki65.bnr.ca (Stuart MacMartin)
  4. Subject: Re: zero-length datatype
  5. Message-ID: <1992Sep15.133503.12459@bcrka451.bnr.ca>
  6. Sender: 5E00 Corkstown News Server
  7. Organization: Bell-Northern Research Ltd., Ottawa, Canada
  8. References: <TMB.92Sep12212544@arolla.idiap.ch> <1992Sep14.133224.6301@cadsun.corp.mot.com>
  9. Distribution: comp
  10. Date: Tue, 15 Sep 1992 13:35:03 GMT
  11. Lines: 38
  12.  
  13. There are a few problems with void objects of 0 size.
  14. These are all related to the question: "How do I handle references
  15. from one object to a void object?".  
  16.  
  17. 1. Databases need to have a unique object id for each object.
  18.    Many oid schemes include an offset into a data record.
  19.  
  20.    Databases could be changed to support void, but many would
  21.    do this by allocating storage for void objects anyway.
  22.  
  23. 2. Ditto for in-core and pointers.  Are the addresses of different
  24.    void values going to be different?  (Or is there exactly one
  25.    void value?)
  26.  
  27. 3. Some implementations of malloc do not work with 0 bytes.
  28.    And what should malloc (or new) return in this case?
  29.    See points 2 and 4.  Is the solution for malloc to allocate
  30.    one byte in this case?
  31.  
  32. 4. If we decide that there is only (exactly) one void object, then
  33.    what should its id/address be?  Will this conflict with any
  34.    database or program?  Must C++ specify the id in this case?
  35.    Can it?
  36.  
  37. 5. What does (void *) mean?  Generic pointer, or pointer to a type
  38.    of size 0?
  39.  
  40. One way of handling these difficulties might be to say that void is a
  41. base type that cannot be instantiated.  It can be part of a template
  42. definition, but cannot be created, passed or returned.  That is,
  43. returning a void has the same meaning as now: it is not returning
  44. a parameter.  This adds yet another special case to the language.
  45.  
  46. Stuart
  47. --
  48. : Stuart MacMartin                                    email: sjm@bnr.ca      :
  49. : Bell-Northern Research                              phone: (613) 763-5625  :
  50. : PO Box 3511, Stn C, Ottawa, K1Y-4H7, CANADA    Standard disclaimers apply. :
  51.