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