comp.lang.ada
 help / color / mirror / Atom feed
From: "chris.danx" <spamoff.danx@ntlworld.com>
Subject: In a pickle.
Date: Wed, 24 Jul 2002 18:58:12 +0100
Date: 2002-07-24T18:58:12+01:00	[thread overview]
Message-ID: <vVB%8.21825$rn5.2410659@news11-gui.server.ntli.net> (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








             reply	other threads:[~2002-07-24 17:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-24 17:58 chris.danx [this message]
2002-07-24 20:30 ` In a pickle 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
replies disabled

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