home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
- From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
- Subject: Re: Zero-length structures and pointer comparisons
- Message-ID: <9235623.26370@mulga.cs.mu.OZ.AU>
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- References: <BzCG7K.2sG@frumious.uucp> <1992Dec18.192202.17023@ucc.su.OZ.AU> <1992Dec18.204337.3084@lth.se> <1992Dec19.202043.20366@ucc.su.OZ.AU>
- Date: Mon, 21 Dec 1992 12:02:43 GMT
- Lines: 57
-
- maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
-
- >However, lets consider that Unix file names are 'pointers' to files,
- >and that links are allowed.
- >
- >Then the average program cant tell if two file names point to
- >the same file or not, since computing the inode number is the only
- >way to do that, and only super users can do this calculation.
- >(Imagine I'm right even if this isnt the case. Is it the case?)
-
- No. Computing the inode number is not a privileged operation.
-
- >Would this make such a system 'unworkable'?
-
- Not if the system had mandatory (as opposed to advisory) locks.
-
- >The issue is whether pointers must provide any more functionality
- >than the ability to access an object, that is, whether object
- >identity can be established by pointer comparisons.
-
- Like it or not (in many ways I don't!), it seems that this principle
- is firmly entrenched in C++. Consider the requirement
- empty classes must have non-zero sizes, etc.
-
- >I suggest that whole classes of software can be written that
- >do not rely on the ability to test if two pointers refer
- >to the same object or not, other types of software require
- >this information.
- >
- >Perhaps we can conceive two types of pointers, type 1
- >provides no comparisons at all, type 2 allows equality test.
- >
- >Most of the code I've written uses type 1, and most uses
- >of type 2 could be rewritten as type 1.
-
- Equality tests are often needed in assignment operators, to
- check for the special case of x=x.
-
- >In those cases where type 2 pointers are desirable, it
- >seems reasonable to restrict them to pointers
- >to objects created directly by me, and not the operating
- >system.
- >
- >Thus I would like to see the ARM == rewritten so the
- >results of == on externally derived or otherwise mangled
- >pointers are implementation defined.
-
- As I said in a previous post, I think that this is already
- the case for C, and I expect it to be the same for C++
- when the ANSI or ISO C++ standard finally comes out.
- Once you have invoked the operating system, all bets are off.
-
- --
- Fergus Henderson fjh@munta.cs.mu.OZ.AU
- This .signature virus is a self-referential statement that is true - but
- you will only be able to consistently believe it if you copy it to your own
- .signature file!
-