home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / cplus / 1800 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.3 KB  |  49 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!uunet.ca!frumious!pat
  3. From: pat@frumious.uucp (Patrick Smith)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <BzCG7K.2sG@frumious.uucp>
  6. Date: Wed, 16 Dec 1992 08:42:55 GMT
  7. References: <9234423.15066@mulga.cs.mu.OZ.AU> <1992Dec9.133956.29659@lth.se> <1992Dec9.191606.5665@lucid.com>
  8. Organization: None
  9. Lines: 38
  10.  
  11. dag@seldon.control.lth.se (Dag Bruck) writes:
  12. | Suggested semantics: for any pointers p and q:
  13. |
  14. |       p == q   <=>   ptrcmp(p,q) == 0
  15. |
  16. |       p != q   <=>   ptrcmp(p,q) != 0
  17. |
  18. |       ptrcmp(p,q) < 0   <=>   ptrcmp(q,p) > 0
  19.  
  20.  
  21. And transitivity:
  22.  
  23.    ptrcmp(p,q) <= 0 && ptrcmp(q,r) <= 0   =>   ptrcmp(p,r) <= 0
  24.    ptrcmp(p,q) <= 0 && ptrcmp(q,r) <  0   =>   ptrcmp(p,r) <  0
  25.    ptrcmp(p,q) <  0 && ptrcmp(q,r) <= 0   =>   ptrcmp(p,r) <  0
  26.  
  27.  
  28. jss@lucid.com (Jerry Schwarz) writes:
  29. |And
  30. |
  31. |       if p < q is defined,  ptrcmp(p,q) < 0   <=>  p < q
  32.  
  33.  
  34. This strikes me as nice to have, but not essential.
  35. Many applications of ptrcmp wouldn't need this property at all
  36. (eg. using ptrcmp to navigate through a binary tree, with no
  37. additional requirement on the ordering other than that it be
  38. an ordering).
  39.  
  40. On the other hand, this might be fairly cheap, given that
  41. we're already insisting on
  42.  
  43.    p == q   =>   ptrcmp(p,q) == 0
  44.  
  45. -- 
  46. Patrick Smith
  47. uunet.ca!frumious!pat
  48. pat%frumious.uucp@uunet.ca
  49.