comp.lang.ada
 help / color / mirror / Atom feed
From: "Mark Lundquist" <mlundquist2@attbi.com>
Subject: Re: List container strawman 1.3
Date: Wed, 05 Dec 2001 23:59:31 GMT
Date: 2001-12-05T23:59:31+00:00	[thread overview]
Message-ID: <DxyP7.309$w85.20109@rwcrnsc54> (raw)
In-Reply-To: DpxP7.50285$xS6.83694@www.newsranger.com


"Ted Dennison" <dennison@telepath.com> wrote in message
news:DpxP7.50285$xS6.83694@www.newsranger.com...
> In article <aewP7.2149$dp6.152302@rwcrnsc54>, Mark Lundquist says...
> >Ted, why does a list need to "know" when its iterators go away?
> >
> >Did you mean to say that safe iterator needs to know when its list has
gone
> >away?
>
> Yes in both cases.
>
> The iterator needs to know when its list goes away, so that users don't
try to
> whack at deallocated memory using the iterator. The list itself will have
to
> keep a mini-list of iterators to support invalidating iterators whoose
> pointed-to item is removed. The list needs to know when an iterator has
gone
> away so that the iterator's entry can be removed from this internal list
of
> iterators.

That's what I figured you had in mind :-)...

Is there an advantage of this over the approach I described, viz. lifetime
"binding" of an iterator to a list using an access discriminant?  Maybe I'm
missing something...

In the access discriminator way, any state of affairs that could give rise
to a dangling iterator results in a compile-time error, and the safety comes
at no added run-time expense.  The chained iterator approach results in a
run-time exception if a dangling iterator is dereferenced, and it seems like
it takes a lot of overhead to set things up.  Just assigning an iterator

    I, J : Iterator
    .
    .
    I := J;

is going to entail a Finalize of I (unchain it), then an Adjust to link it
back in again.  It would be best to provide the Set procedure from my
example to circumvent this, but then you might as well make the Iterator
limited.

Also of course the control structure for the list must be allocated from the
heap, so that it can outlive the user's handle (since we have to keep the
iterator chain alive until the last one goes away)...

-- mark






  reply	other threads:[~2001-12-05 23:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-05  0:08 List container strawman 1.3 Ted Dennison
2001-12-05  0:26 ` Ted Dennison
2001-12-05  1:31   ` Vincent Marciante
2001-12-05  8:35   ` Jean-Marc Bourguet
2001-12-05 15:02     ` Ted Dennison
2001-12-05 13:22   ` John English
2001-12-05 16:42     ` Ted Dennison
2001-12-05 21:22       ` Mark Lundquist
2001-12-05 21:38         ` Mark Lundquist
2001-12-05 22:42         ` Ted Dennison
2001-12-05 23:59           ` Mark Lundquist [this message]
2001-12-06 14:50             ` Iterator approach (was: List container strawman 1.3) Ted Dennison
2001-12-06 16:19               ` Ted Dennison
2001-12-06 17:41               ` Mark Lundquist
2001-12-06 17:57                 ` Preben Randhol
2001-12-07 16:19                 ` Ted Dennison
2001-12-06 17:47           ` List container strawman 1.3 Darren New
2001-12-07 16:00             ` Ted Dennison
2001-12-07 17:18               ` Darren New
2001-12-09 14:04                 ` Mark Lundquist
2001-12-05 16:44     ` Simon Wright
2001-12-05  2:57 ` Jeffrey Carter
2001-12-05  3:45   ` Ted Dennison
2001-12-05  6:01     ` Jeffrey Carter
2001-12-05 13:17 ` John English
2001-12-05 15:46   ` Ted Dennison
2001-12-05 18:03     ` Georg Bauhaus
2001-12-05 18:30       ` Ted Dennison
2001-12-06 13:56         ` Georg Bauhaus
2001-12-06 14:59           ` Ted Dennison
2001-12-06  0:18       ` Jeffrey Carter
2001-12-06 13:52         ` Georg Bauhaus
2001-12-06 16:56           ` Jeffrey Carter
2001-12-06 19:33             ` Georg Bauhaus
2001-12-07 16:22               ` Ted Dennison
2001-12-05 16:53   ` Ted Dennison
2001-12-05 17:09   ` Larry Kilgallen
2001-12-06 23:07 ` Nick Roberts
replies disabled

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