home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!haven.umd.edu!wam.umd.edu!krc
- From: krc@wam.umd.edu (Kevin R. Coombes)
- Subject: Re: boolean (was: Re: typedef vs enum)
- Message-ID: <1992Jul23.125431.19324@wam.umd.edu>
- Sender: usenet@wam.umd.edu (USENET News system)
- Nntp-Posting-Host: wam.umd.edu
- Organization: University of Maryland, College Park
- References: <DOUGM.92Jul19222728@titan.cs.rice.edu> <DAVEG.92Jul20220553@synaptx.synaptics.com> <1992Jul21.170922.26941@ucc.su.OZ.AU>
- Date: Thu, 23 Jul 1992 12:54:31 GMT
- Lines: 50
-
- In article <1992Jul21.170922.26941@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- > While we're talking of a boolean type (which has two
- >values equivalent to 0 and 1), how about a ZERO type?
- >
- > Type ZERO only has ONE value---0 of course.
- >
- > What use is it, you ask?
- >
- > Plenty. 0 is very important.
- >
- > How often have you wanted to allow assignment
- >or initialisation of a class to 0 (but not any other value?)
- >
- > For example, if p is a pointer, you can write
- >
- > p=0; // null pointer
- >
- >But if it is a *smart* pointer, you would have to declare
- >assignment of say int->smart, and give a run-time error
- >if the int was non-zero.
- >
- >[There are NO variables of type zero, the type name is, of course 0]
- >
- > class smart {
- > operator=(0) { // set pointer to null state }
- > };
- >
- >Anyone?
- >
- >
- >--
- >;----------------------------------------------------------------------
- > JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- > Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- >;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-
- I liike this idea (but don't expect it to go anywhere). After all,
- 0 is a type different from any other integer. If, for example, you have
- an overloaded function
-
- void f(long);
- void f(void *);
-
- the call f(0) is an error, because it is ambiguous. No other integer
- has that property.
-
- But shouldn't the type be called NULL? :-)
-
- Kevin Coombes <krc@math.umd.edu>
-
-