comp.lang.ada
 help / color / mirror / Atom feed
* In a pickle.
@ 2002-07-24 17:58 chris.danx
  2002-07-24 20:30 ` Jim Rogers
  2002-07-24 22:59 ` Simon Wright
  0 siblings, 2 replies; 11+ messages in thread
From: chris.danx @ 2002-07-24 17:58 UTC (permalink / raw)


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?


Chris








^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: In a pickle.
@ 2002-07-26  4:40 Grein, Christoph
  2002-07-26 22:57 ` chris.danx
  0 siblings, 1 reply; 11+ messages in thread
From: Grein, Christoph @ 2002-07-26  4:40 UTC (permalink / raw)


See my paper about Safe_Pointers in my home page.

http://home.T-online.de/home/Christ-Usch.Grein/Ada

This discusses in great detail how reference counting pointers can be 
implemented. This might help. This paper has appeared some time ago in Ada 
Letters and also in Ada User Journal. It includes complete software ready to 
use.

HTH

Christoph Grein



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-07-26 22:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox