From: "chris.danx" <chris.danx@ntlworld.com>
Subject: Re: In a pickle.
Date: Thu, 25 Jul 2002 16:49:06 +0100
Date: 2002-07-25T16:49:06+01:00 [thread overview]
Message-ID: <q6V%8.15524$vN6.792864@newsfep2-win.server.ntli.net> (raw)
In-Reply-To: 3D3F0E27.9080303@worldnet.att.net
Jim Rogers wrote:
> 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
ARGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!
Managing all the finalisation calls is a nightmare!
raised PROGRAM_ERROR : aqua-lists-linear-unbounded-doubly.adb:56
caused by finalization of an iterator in a call in a subprogram. I reckon I
know how to fix it, but it will require each iterator modifing subprogram
setting a flag, while basic query ops clear it. Finalization will check the
flag and if it's cleared do nothing, otherwise adjust the iterator.
Think that's ugly? Anyone think of a better way?
next prev parent reply other threads:[~2002-07-25 15:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-24 17:58 In a pickle chris.danx
2002-07-24 20:30 ` Jim Rogers
2002-07-25 13:26 ` chris.danx
2002-07-25 15:49 ` chris.danx [this message]
2002-07-25 22:32 ` chris.danx
2002-07-26 15:43 ` Stephen Leake
2002-07-26 20:27 ` chris.danx
2002-07-26 21:11 ` sk
2002-07-24 22:59 ` Simon Wright
-- strict thread matches above, loose matches on Subject: below --
2002-07-26 4:40 Grein, Christoph
2002-07-26 22:57 ` chris.danx
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox