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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <1992Dec24.005201.1488@microsoft.com>
  6. Date: 24 Dec 92 00:52:01 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Dec18.204337.3084@lth.se> <1992Dec19.202043.20366@ucc.su.OZ.AU> <1992Dec20.201212.8974@lth.se>
  9. Lines: 33
  10.  
  11. In article <1992Dec20.201212.8974@lth.se> dag@bellman.control.lth.se (Dag Bruck) writes:
  12. |The goal was to write data structures that use the ordering of
  13. |pointers to improve search time.  What I need is mechanism that
  14. |compares the pointers -- what they actually point to is not relevant.
  15.  
  16. On the contrary, you DO NOT then need such a mechanism, because alternate
  17. approaches not using pointers can give you similar improvements to search times.
  18.  
  19. |C and C++ has some notion of equality between pointers.  You can
  20. |clobber the semantics of this equality with memory mapping and what
  21. |not, but that is in my view an issue beyond the language.
  22.  
  23. Agreed, as long as *you* stick to the C and C++ notion of equality
  24. between pointers -- which is an extremely limited notion of equality.
  25.  
  26. |I would finally like to return to a claim I made earlier, but nobody
  27. |has commented on (as far as I know).  I belive that even if you
  28. |imposed a total ordering on pointers in a segmented architecture
  29. |(e.g., Inte 8086 family), compilers would be able to handle the
  30. |follwing common case efficiently:
  31. |
  32. |    void zap(int* a, unsigned n)
  33. |    {
  34. |        for (int* p = a; p < a+n; p++)
  35. |            *p = 0;
  36. |    }
  37. |
  38. |and produce the same code as today (without the total ordering).
  39. |After all, the assignment "p = a" says that "p" must point to the same
  40. |segment as "a".  Any comments?
  41.  
  42. You statement is true, but does not imply your intended conclusion, 
  43. namely that thus one can efficiently implement total ordering.
  44.