home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1875 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.7 KB  |  69 lines

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