comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: list strawman
Date: Mon, 07 Jan 2002 19:26:06 GMT
Date: 2002-01-07T19:26:06+00:00	[thread overview]
Message-ID: <iDm_7.7512$cD4.12862@www.newsranger.com> (raw)
In-Reply-To: u7kqu3yux.fsf@gsfc.nasa.gov

In article <u7kqu3yux.fsf@gsfc.nasa.gov>, Stephen Leake says...
>One issue I did not point out is the changes I had to make to the
>spec. In particular, I had to declare "List" as tagged, and use 'class
>in a couple places. Do you have any objections to that?

If you could move the tagged-ness to the private section, I'd prefer that done.
Since its done entirely for implmentation reasons (right?), that's where it
goes. There's no need to dictate taggedness onto someone who might not need it.

>> The List Adjust routine should wipe out any iterator lists, as they
>> belong to the source List (and visa versa), not the target. You
>> don't deal with this.
>
>Hmm. Adjust (List) explicitly sets the new list's iterator list to
>null. The source list iterators are preserved, and the new list has no
>iterators. 

Ahhh, that's right. I see it now.

>> The List Finalize routine needs to invalidate any iterators on the
>> list's iterator list. You don't do this. (The comment says you do,
>> but you just seem to be calling Unchecked_Conversion on the list
>> header, unless I am missing something)
>
>Actually Unchecked_Deallocation. That eventually calls Finalize on the
>iterator list, which should invalidate all of them. A test case
>proving this is needed.

I don't see how this makes the jump from your List object to the iterator
object. In order for an iterator to know that its list is gone, you'd have to
tell the iterator somehow. Something would have to set the Iterator's IA field
to null, or its IA.List or IA.I fields to null or something. Just dynamicly
deallocating the List's iterators from its iterator list isn't going to do that.
Instead you'd leave the iterator's IA field pointing off into space somewhere.
Are you setting that to null somewhere that I'm not seeing?

>There is a tradeoff between putting stuff in Initialize, and doing
>stuff with aggregates when an object is created. If you assign an
>aggregate to a Controlled object, Initialize is _not_ called (LRM 7.6
>(10)). So any place you assign an aggregate to a Controlled object,
>you have to be sure you do everything Initialize would do. I'm pretty
>sure I haven't got that right yet.

I wouldn't call it a trade-off exactly. I use initialize for allocating
nessecary substructures (with default clean values), and nothing else. Finalize
needs to undo that, along with undoing any bookeeping work that other routines
might do. Adjust needs to take the copied fields and make newly-allocated unique
copies of any pointed-to objects (or not in the case of iterators). Every
Initialize will eventually get a finalize, as will every Adjust.

I think it would have helped me to see a matrix something like this:

Operation
Example           Controlled Primitives called
------------------------------------------------------------
Declaration  
A : Mytype;       Initialize (A);
Initialization 
A : Mytype := B;  Adjust (A);
Assignment
A := B;           Finalize (A); {fields copied} Adjust (A);

{Note: Often a temporary B will be created during assinment too,
in which case we have:
                 Adjust (Temp_B); Finalize (A); Adjust (A); Finalize (Temp_B);
)

>I just noticed that the No_Item exception is declared within the
>generic Lists.Unbounded package, which means we get a different one
>for each instantiation. We probably want to move that up to Lists or
>ACL.

That's a good point. We may want to move that up when we get more than one. Then
again, we could leave a renaming of it down here too.

>> It also looks like it is possible to get rid of all list searches in iterator
>> manipulations. <snip>
>
>Are you sure you are considering all the nasty things users can do?
>Like declaring several iterators to a list, but not actually using
>them for anything.

Yup. It doesn't matter. This is related to my previous point about getting rid
of dynamic allocations. If the list's iterator list node is actually part of the
iterator itself, then the iterator can just go straight to its own node to move
itself from one iterator list to another. Unfortunately, this requires that the
List's iterator lists are doubly-linked. It gets to be a bit hairy.

>> A nice side benifit to doing this is that iterators can be
>> made to travel with the element when it chages lists (via Splice).
>> We will have to discuss if this is a Bad Thing or a Good Thing from
>> a user perspective.
>
>I think that's a Bad Thing. But if it were clearly documented, maybe
>it would be ok.

I think its mostly an issue of how it could be used. If its reasonable to do
splices inside of an iteration loop, then we may want to do it. I'm not feeling
creative enough to visualise a need for it though.

>> Anyway, sorry for all the criticism. Good work. Believe me, I know
>> how much effort it is to try to get this right. :-)
>
>Hey, it was actually fun! It made me appreciate having written SAL;
>having a working low-level list abstraction makes it easier to
>implement the safe iterators. And doing this clarified some of the
>design issues in SAL.

I think it will actually be quite useful for 3rd-party component libraries to do
this, as they will be able to provide their own functionality as sort of an
extension to the "training-wheels" standard version. :-)

>You might consider using my Test_Storage_Pools package in your test
>harness; it makes it possible to find memory leaks as part of testing.

I actually have been checking for leaks too, with some code internal to the
package. I essentially increment an alloction counter at every "new" call,
decrement it at every Unchecked_Deallocation, and make sure its 0 when the Empty
list (declared in the spec) gets finalized. Its not task-safe, but it works for
a test.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



  parent reply	other threads:[~2002-01-07 19:26 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-06 20:55 list strawman Stephen Leake
2002-01-07 15:56 ` Ted Dennison
2002-01-07 15:57   ` Ted Dennison
2002-01-07 16:33   ` Stephen Leake
2002-01-07 16:37     ` Stephen Leake
2002-01-07 19:31       ` Ted Dennison
2002-01-07 19:26     ` Ted Dennison [this message]
2002-01-07 22:05       ` Stephen Leake
2002-01-07 22:51         ` Ted Dennison
2002-01-08  0:48           ` Steven Deller
2002-01-08 15:32             ` Ted Dennison
2002-01-08 15:43               ` Jean-Marc Bourguet
2002-01-08 17:07                 ` Ted Dennison
2002-01-08 17:21                   ` Jean-Marc Bourguet
2002-01-08 19:12                     ` Ted Dennison
2002-01-09  8:09                       ` Jean-Marc Bourguet
2002-01-09 18:37                         ` Ted Dennison
2002-01-11  9:37                           ` Jean-Marc Bourguet
2002-01-11 17:03                             ` Ted Dennison
2002-01-11 17:47                               ` Jeffrey Carter
2002-01-12 15:10                               ` Jean-Marc Bourguet
2002-01-13 10:18                                 ` Jean-Marc Bourguet
2002-01-14 16:02                                 ` Ted Dennison
2002-01-14 16:22                                   ` Jean-Marc Bourguet
2002-01-08 19:57                     ` Steven Deller
2002-01-08 19:54                 ` Steven Deller
2002-01-08 19:54               ` Steven Deller
2002-01-08 20:46                 ` Ted Dennison
2002-01-08 21:21                   ` Stephen Leake
2002-01-08 21:49                     ` Ted Dennison
2002-01-09  9:21                       ` Thomas Wolf
2002-01-09 15:20                         ` Ted Dennison
2002-01-09 15:53                           ` Stephen Leake
2002-01-09 21:21                             ` Ted Dennison
2002-01-09 17:42                         ` Mark Lundquist
2002-01-09 21:02                           ` Jeffrey Carter
2002-01-10  8:47                             ` Thomas Wolf
2002-01-11 17:38                               ` Jeffrey Carter
2002-01-11 21:52                                 ` Chad Robert Meiners
2002-01-12  5:45                                   ` Jeffrey Carter
2002-01-12 22:20                                     ` Chad R. Meiners
2002-01-13 17:03                                       ` Jeffrey Carter
2002-01-13 23:47                                         ` Chad R. Meiners
2002-01-14  1:32                                           ` Ted Dennison
2002-01-14  5:12                                           ` Jeffrey Carter
2002-01-14  5:12                                           ` Jeffrey Carter
2002-01-10 14:39                           ` Ted Dennison
2002-01-11  5:34                             ` Mark Biggar
2002-01-12 12:20                               ` Simon Wright
2002-01-14 14:53                                 ` Matthew Heaney
2002-01-16  5:56                                   ` Simon Wright
2002-01-18  9:15                           ` Overridability of _private_ predefined "=" [was Re: list strawman] Vincent Marciante
2002-01-19 16:58                             ` Vincent Marciante
2002-01-19 22:42                               ` Nick Roberts
2002-01-09  3:10                     ` list strawman Ted Dennison
2002-01-09 19:09                       ` Ted Dennison
2002-01-08 21:26               ` Georg Bauhaus
2002-01-08 22:13                 ` Ted Dennison
2002-01-09 20:52               ` Jeffrey Carter
2002-02-17 15:04 ` Florian Weimer
2002-02-17 15:05 ` Florian Weimer
2002-02-18  1:43   ` Stephen Leake
2002-02-18  8:57     ` Florian Weimer
replies disabled

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