comp.lang.ada
 help / color / mirror / Atom feed
From: "chris.danx" <spamoff.danx@ntlworld.com>
Subject: Re: In a pickle.
Date: Thu, 25 Jul 2002 23:32:38 +0100
Date: 2002-07-25T23:32:38+01:00	[thread overview]
Message-ID: <L0%%8.573$AJ3.17195@newsfep3-gui.server.ntli.net> (raw)
In-Reply-To: 3D3F0E27.9080303@worldnet.att.net

Jim Rogers wrote:
> 
> That is my understanding of how assignment works.

Thanks.

> Jim Rogers
> 

Try posting this again (for the third time). :(

The task of implementing iterators is proving very difficult, can anyone 
please offer some guidance/pointers?  I want operations on a node which 
would invalidate iterators to take place only when one iterator 
references a node.  For example deleting a node should only occur when 
one, and only one iterator points to it (if more than one iterator 
points to the node an exception should occur).

First I tried a scheme involving counting the number of iterators that 
reference a node, but this approach lead to a very complex 
implementation, so it's back to the drawing board. :(


One difficulty encountered is in signalling that we are done with a 
node.  Suppose the statement

Iterator := Next (Iterator);

is allowed.  Prior to the call Iterator points to a node in the list (if 
it did not Next would raise Invalid_Iterator_Error), which it will leave 
after the assignment.  The node needs to know an iterator has left, but 
how?  Finalize can decrement the counter but it's difficult to control 
exactly when.  Consider this...

function Next (Iterator : in Iterator_Type) return Iterator_Type is
    Temp : Iterator_Type;
begin
    ...
    return Temp;
end Next;

After return Temp; Temp will be finalized so we need to record that temp 
is just temporary.  Then we have the problem of intelligently adjusting 
the iterator on the left hand-side. :(

Now I know why John English skipped the issue in "ada: the craft..." (I 
didn't fully appreciate Johns' warning on this) and why other list 
implementations either skip the issue or are quite complex.

Is there a better solution to this problem???


Thanks for your time,
Chris




  parent reply	other threads:[~2002-07-25 22:32 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
2002-07-25 22:32   ` chris.danx [this message]
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