From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7350da5176edec2c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-26 13:27:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!demon!peernews!peer.cwci.net!newspeer1-gui.server.ntli.net!ntli.net!newsfep3-gui.server.ntli.net.POSTED!53ab2750!not-for-mail Message-ID: <3D41B09C.2000106@ntlworld.com> From: "chris.danx" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1b) Gecko/20020721 X-Accept-Language: en-gb, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: In a pickle. References: <3D3F0E27.9080303@worldnet.att.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Inktomi-Trace: pc3-bbrg1-2-cust234.ren.cable.ntl.com 1027715264 21136 80.5.140.234 (26 Jul 2002 20:27:44 GMT) Date: Fri, 26 Jul 2002 21:27:08 +0100 NNTP-Posting-Host: 80.3.128.4 X-Complaints-To: abuse@ntlworld.com X-Trace: newsfep3-gui.server.ntli.net 1027715265 80.3.128.4 (Fri, 26 Jul 2002 21:27:45 BST) NNTP-Posting-Date: Fri, 26 Jul 2002 21:27:45 BST Organization: ntl News Service Xref: archiver1.google.com comp.lang.ada:27425 Date: 2002-07-26T21:27:08+01:00 List-Id: Stephen Leake wrote: > "chris.danx" writes: > > I've just put up my Grace.Lists implementation; see > > http://users.erols.com/leakstan/Stephe/index.html > > It does "safe" iterators; iterators are invalidated if the item they > point to is deleted, etc. Nice. >>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). > > > Grace does not require this. I guess you're doing something like > "reference counting garbage collection". > > So Grace iterators are not exactly what you want. But there may be > some implementation ideas you can use. I am undecided whether to invalidate all iterators like your Grace implementation or disallow deletion when multiple iterators point to the same iterator. Chris Greins code has shed some light on the using aggregates which I was unaware of and this makes the use of temporaries unnecessary (didn't know how to use tagged types with aggregates). >>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. :( > > Complexity is sometimes necessary :). It's a simple idea though. Why do simple ideas have to be so complex? :) > Yes, using temporaries causes complexity. You might try using > aggregates instead; that gives you more direct control over what's > going on. Neither Initialize nor Finalize is called on an aggregate. Will do! >>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. > > Welcome to the club :). Implementing the Grace iterators was much more > challenging than I thought it would be. And I haven't really tested it > yet; that's more work than I want to do right now. Glad to see I'm not the only one :) >>Is there a better solution to this problem??? > > Since I'm not sure what your real top level problem is, I can't say. > Can you say more about why you want reference counted iterators? I don't really know why. My logic was that if the programmer calls delete on a node referenced by more than one iterator, there's a good chance it is an error and they should be warned. I suppose a better idea would be to let the programmer delete the node and raise a constraint error when an attempt is made to use the iterator (just realised the programmer may really want to delete the node). I'm really not sure what do, but after looking at Chris Greins paper the method of pointing Iterators directly at nodes doesn't seem so good. Maybe pointing Iterators to a unique object which points the node is better. Need to experiment and have a look at how others have got round this problem. Chris -- to reply change 'spamoff' to 'chris'