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