From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7350da5176edec2c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-24 13:30:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn4feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3D3F0E27.9080303@worldnet.att.net> From: Jim Rogers User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: In a pickle. References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 24 Jul 2002 20:30:03 GMT NNTP-Posting-Host: 12.86.36.235 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1027542603 12.86.36.235 (Wed, 24 Jul 2002 20:30:03 GMT) NNTP-Posting-Date: Wed, 24 Jul 2002 20:30:03 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:27368 Date: 2002-07-24T20:30:03+00:00 List-Id: chris.danx wrote: > Hi, > > Is there a resolution to the following problem that allows convienant > assignment of iterators? An iterator points to a node in a list, like this > > -- Bi-Directional Iterator definition for positions within > -- objects of List_Type. > -- > type Iterator_Type is new Ada.Finalization.Controlled > with record > List : List_Base_Access; > Position : Node_Access; > end record; > > While more than one iterator points to a node it cannot be deallocated, with > the number of iterators pointing to the node, recorded in the node itself. > The problem is assignment! If we do > > Iterator := Next (Iterator); > > The iterator is assigned to the next position, but the count of iterators > isn't decremented so the node always thinks an iterator is on it. > > I've just noticed something in Cohen that may help but am not sure if my > interpretation is correct. > > At the top of page 573 he says "The target variable in an assignment > statement is finalized just before a new value is about to be copied to that > variable". > > Does this mean that in the above assignment Iterator is finalized after Next > (Iterator) is evaluated but before the assignment takes place? That would > mean that a suitably coded finalize would do the job, correct? That is my understanding of how assignment works. Jim Rogers