home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / cplus / 1868 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.0 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!mailgzrz.TU-Berlin.DE!cs.tu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!news.lth.se!dag
  2. From: dag@bellman.control.lth.se (Dag Bruck)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <1992Dec20.201212.8974@lth.se>
  6. Date: 20 Dec 92 20:12:12 GMT
  7. References: <BzCG7K.2sG@frumious.uucp> <1992Dec18.192202.17023@ucc.su.OZ.AU> <1992Dec18.204337.3084@lth.se> <1992Dec19.202043.20366@ucc.su.OZ.AU>
  8. Sender: news@lth.se
  9. Organization: Department of Automatic Control, Lund, Sweden
  10. Lines: 40
  11.  
  12. In <comp.std.c++> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  13. >>>
  14. >>>In fact, p==q iff objects equal is unimplementable on some machines.
  15. >>>That is, even the existing ARM requirement is unworkable.
  16. >
  17. >Perhaps we can conceive two types of pointers, type 1 
  18. >provides no comparisons at all, type 2 allows equality test.
  19.  
  20. I think we're sliding away from the original discussion.
  21.  
  22. The goal was to write data structures that use the ordering of
  23. pointers to improve search time.  What I need is mechanism that
  24. compares the pointers -- what they actually point to is not relevant.
  25.  
  26. Let me try to put it differently: the element type is "pointer to X",
  27. not "X" itself.
  28.  
  29. C and C++ has some notion of equality between pointers.  You can
  30. clobber the semantics of this equality with memory mapping and what
  31. not, but that is in my view an issue beyond the language.
  32.  
  33. I would finally like to return to a claim I made earlier, but nobody
  34. has commented on (as far as I know).  I belive that even if you
  35. imposed a total ordering on pointers in a segmented architecture
  36. (e.g., Inte 8086 family), compilers would be able to handle the
  37. follwing common case efficiently:
  38.  
  39.     void zap(int* a, unsigned n)
  40.     {
  41.         for (int* p = a; p < a+n; p++)
  42.             *p = 0;
  43.     }
  44.  
  45. and produce the same code as today (without the total ordering).
  46. After all, the assignment "p = a" says that "p" must point to the same
  47. segment as "a".  Any comments?
  48.  
  49.         -- Dag
  50.  
  51.         
  52.