From: Jim Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: In a pickle.
Date: Wed, 24 Jul 2002 20:30:03 GMT
Date: 2002-07-24T20:30:03+00:00 [thread overview]
Message-ID: <3D3F0E27.9080303@worldnet.att.net> (raw)
In-Reply-To: vVB%8.21825$rn5.2410659@news11-gui.server.ntli.net
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
next prev parent reply other threads:[~2002-07-24 20:30 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 [this message]
2002-07-25 13:26 ` chris.danx
2002-07-25 15:49 ` chris.danx
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