home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1921 < prev    next >
Encoding:
Text File  |  1992-12-25  |  4.1 KB  |  90 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: <9236103.3697@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <9235622.25587@mulga.cs.mu.OZ.AU> <5458@holden.lulea.trab.se>
  9. Date: Fri, 25 Dec 1992 16:26:43 GMT
  10. Lines: 78
  11.  
  12. jbn@lulea.trab.se (Johan Bengtsson) writes:
  13.  
  14. >Fergus James HENDERSON (fjh@munta.cs.mu.OZ.AU) wrote:
  15. >: jbn@lulea.trab.se (Johan Bengtsson) writes:
  16. >
  17. >: >Markku Sakkinen (sakkinen@jyu.fi) wrote:
  18. >: >: BTW, actually total order is
  19. >: >: a simple thing within an OODB _because_ the identity of each object
  20. >: >: is assured not to change.
  21. >: >
  22. >: >It would impose severe restrictions on how the virtual address space
  23. >: >could be used though.  The OODBMS may end up in a situation where
  24. >: >it can't get a persistent object into memory, not because it has used up
  25. >: >all virtual memory addresses, but because all unused virtual memory
  26. >: >adresses would violate the total ordering property.
  27. >
  28. >: I thought that the idea was that for OODBMSs, you DON'T compare virtual
  29. >: addresses for pointers to persistent objects, instead you compare the object
  30. >: ids. Maybe someone could explain the problems in a little more detail?
  31. >
  32. >As Stuart MacMartin said, if the OODBMs uses objects of class Handle
  33. >(never mind the name) to represent references to persistent objects
  34. >you will need to have
  35. >
  36. >ptrcmp(Handle,Handle), if you want templates to compare Handles the
  37. >same way they compare pointers.  The OODBMs should provide that.
  38. >Also it should provide ptrcmp(Handle,void*) and ptrcmp(void*,Handle).
  39.  
  40. Actually, I don't think that these last two are necessary (see below).
  41.  
  42. >_Some_ OODBMs use void* as their Handles (they play tricks by
  43. >using virtual memory mapping to persistent storage), so they must
  44. >provide a ptrcmp(void*,void*) that can tell the difference between
  45. >pointers to persistent objects and normal memory pointers.  For persistent
  46. >objects, it then finds the object ids and makes the comparison.
  47. >
  48. >My point is that this may be difficult, or slow (although I don't
  49. >really have any data on that).  The alternative is to simply compare
  50. >the void pointers, even for pointers to persistent objects, however
  51. >that imposes the unacceptable restrictions I described in my previous
  52. >posting.
  53.  
  54. For these OODBMSs, (void *) == (void *) will be implemented simply by
  55. comparing the void pointers. The statement in the ARM that "two pointers
  56. to the same object compare equal" will NOT always hold.
  57. (As you have been arguing, to implement == with this guarantee would be
  58. too difficult and too inefficient).
  59.  
  60. Since these systems aren't going to be standard-compliant anyway,
  61. unless we change the standard, I don't really know what we can
  62. conclude from them with regard to ptrcmp().
  63.  
  64. >A more difficult issue is what do you do if there is more than one
  65. >OODBMs in use, or more realistically, one OODBM, and one distributed
  66. >object manager (that similarly uses Handles to distributable objects).
  67. >Who is responsible for providing the needed ptrcmp(OODB_Handle,Distr_Handle)
  68. >and ptrcmp(Distr_Handle,OODB_Handle) functions?  This may become
  69. >totally unmanageable if handle-based schemes become common.
  70.  
  71. The template classes are always going to be comparing objects of the
  72. same type. If you have a collection of OODB_Handles, then use
  73. ptrcmp(OODB_Handle, OODB_Handle). If you have a collection of
  74. Distr_Handles, then use ptrcmp(Distr_Handle, Distr_Handle). If you have
  75. a collection that you want to use to store both Distr_Handles and
  76. OODB_Handles, then you will have to write your own type-safe union
  77. class Any_Handle anyway, and then *you* are going to be the one who
  78. will implement ptrcmp(Any_Handle, Any_Handle). There is no need for
  79. ptrcmp(Distr_Handle, OODB_Handle).
  80.  
  81. >Hope this is a little bit clearer.
  82.  
  83. Quite a bit clearer. Thanks!
  84.  
  85. -- 
  86. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  87. This .signature virus is a self-referential statement that is true - but 
  88. you will only be able to consistently believe it if you copy it to your own
  89. .signature file!
  90.