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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Zero-length structures and pointer comparisons
  5. Message-ID: <1992Dec16.150144.6004@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1992Dec9.075125.22405@lth.se> <1992Dec12.154918.2220@ucc.su.OZ.AU> <1992Dec14.225659.24225@microsoft.com>
  10. Date: Wed, 16 Dec 1992 15:01:44 GMT
  11. Lines: 75
  12.  
  13. In article <1992Dec14.225659.24225@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
  14. >In article <1992Dec12.154918.2220@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  15. >|which cannot break existing implementations but provides a  total
  16. >|order by way of a library function? If so, can we put this to
  17. >|the library WG?
  18. >
  19. >I think some flavor of "ptrcmp" makes sense on those implementations that
  20. >support casting pointers to integrals and back, and probably doesn't make
  21. >sense on those implementations that don't support the pointer/integral casts.
  22.  
  23.     Why not?
  24. >
  25. >In either case, I would ask what kind of sense it makes to write a "standard"
  26. >that *requires* a certain behavior of *some* implementation but doesn't
  27. >*require* that behavior of *all* implementations?  How do you justify such
  28. >a dichotomy?
  29.  
  30.     ptrcmp is standard, required function, it must yield a total
  31.     order.
  32.  
  33.     No dichotomy. ptrcmp is mandatory.
  34.  
  35.     I'm not yet convinced it need bear ANY relation to
  36.     ==, !=, < etc on pointers.
  37.  
  38.     In that case it is implementable on all systems
  39.     where (opinion follows, please correct errors)
  40.  
  41.     a) void* is big enough to hold all pointer types
  42.     b) conversions always pad systematically
  43.     c) bitwise comparison is done 
  44.     d) the bits of a pointer cannot be magically changed by the system
  45.     e) a pointer is implemented as an object in contiguous storage
  46.  
  47. c) ensures a total order by injective mapping of pointers to integers,
  48. NOT necessarily long though.
  49.  
  50. b) ensures determinism
  51.  
  52. a) ensures ptrcmp(void*,void*) can be called without loss of bits
  53.  
  54. Such a function allows pointers to be, say, sorted, without any
  55. expected correlation with the order of the objects they point to.
  56.  
  57. I am not sure of the wisdom or workability of having any additional
  58. rules relating ==, < etc to ptrcmp.
  59.  
  60. >
  61. >cast, and for the proposed "ptrcmp" macro.  Then, on Lisp machines, or 
  62. >C++ OODBMS's or whatever systens would find the total ordering 
  63. >practically unsupportable in their environment, they simply would not implement
  64. >the "common extension."  This would be a quality of implementation issue then,
  65. >not an issue of conformance.
  66.  
  67.     These 'lisp' machines must break rule (d) above then?
  68.  
  69. >
  70. >In any case, "ptrcmp" would be a misnomer, because what is being compared
  71. >is *not* pointers, but rather the underlying *assumed* implementation of 
  72. >pointers using machine addresses.  The correct name might be something like 
  73. >"addrcmp" then, so as to not further confuse programmers on the difference
  74. >between language and implementation.
  75.  
  76.     I suggest the *actual* implementation be what is compared.
  77.  
  78.     Certainly, (e) might cause problems on the 80x86 where part of the
  79. pointer is implicit and not physically stored. Does it *actually*
  80. cause this problem?
  81.  
  82.  
  83. -- 
  84. ;----------------------------------------------------------------------
  85.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  86.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  87. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  88.