home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,481 of 33,346   
   Kaba to Francis Glassborow   
   Re: Layered data structures   
   15 Jul 12 21:28:26   
   
   From: kaba@nowhere.com   
      
   15.7.2012 21:44, Francis Glassborow wrote:   
   > I am having a big problem trying to understand what the problem is   
   > that you are trying to solve. Given that you want the object of type   
   > A to be immutable as long as any object of type B is 'referring' to   
   > it is it also a requirement that all objects of type B reference an   
   > identical version of the object of type A?   
      
   An object of type A may be referred to zero, one, or multiple times by   
   objects of type B.   
      
   In general, the objects of type B compute something out of objects of   
   type A. This computation recovers some structure that is contained   
   implicitly in A. The B makes this structure explicit, and does this by   
   referring to things in A in a new way. Referring to things most often   
   means having iterators to A, since iterators encapsulate pointing to a   
   part of A.   
      
   If an object of type A is changed, or even destructed, then its parts   
   (iterators) may be invalidated. This makes the state of a referring   
   object of type B invalid. This is the problem I would like to guard   
   against; it should not be possible for a user to place an object in an   
   invalid state.   
      
   > If the answer to that is 'yes', why does it matter whether the   
   > objects of type B are simultaneously using the same A object rather   
   > than sequentially doing so?   
      
   I'm not sure I understand what you mean by simultaneous or sequential   
   here.   
      
   > If sequentially the A object may well be changed during the sequence   
   > if there is ever a moment when no B object currently holds a   
   > reference to that A object.   
   >   
   > So:   
   >   
   > 1) If all B objects MUST reference an identical A object then the A   
   > object needs to be (deeply) immutable and the A object Must have a   
   > reference counter to inhibit its destruction whilst any B object is   
   > referring to it.   
      
   True, if 'all B objects' is understood as being those B objects which   
   refer to a given A object.   
      
   > 2) If B objects need not reference an identical A object then each B   
   > object should hold its own copy of the A object and destroy that   
   > copy when it has finished with it.   
      
   This is problematic in two ways. First, as already stated, the   
   identity of the parts is often important (in my problem it   
   is). Second, duplicating identical objects wastes resources.   
      
   --   
   http://kaba.hilvi.org   
      
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca