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-Thread: 103376,70414f56d810c10c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.38.134 with SMTP id g6mr9791954pbk.6.1316817763675; Fri, 23 Sep 2011 15:42:43 -0700 (PDT) MIME-Version: 1.0 Path: lh7ni3508pbb.0!nntp.google.com!news1.google.com!goblin3!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Fri, 23 Sep 2011 17:42:39 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <9f37b726-d80b-4d24-bf3f-28a14255f7fd@s20g2000yql.googlegroups.com> <148cxoyabima2.16mz6xwdph2hj.dlg@40tude.net> <01a1374f-59ab-40be-9e39-0640cb2a513d@n35g2000yqf.googlegroups.com> <1fp2o673mu9az$.d9loz1zbcl0d.dlg@40tude.net> <14tiipigyejtc$.hyp7e82egqwq$.dlg@40tude.net> <34d856bd-19a3-4bbf-b9d8-c0f100000ef4@k7g2000vbd.googlegroups.com> <1tpl2pc36ptr4$.txv4v3wmkjlm.dlg@40tude.net> <1malv6h6q31j3.uz9ws5j0glnm.dlg@40tude.net> <82ipojfw85.fsf@stephe-leake.org> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1316817762 29859 69.95.181.76 (23 Sep 2011 22:42:42 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 23 Sep 2011 22:42:42 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-RFC2646: Format=Flowed; Original Xref: news1.google.com comp.lang.ada:18106 Date: 2011-09-23T17:42:39-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:xumuqaannoov$.18le1ojsi30l8.dlg@40tude.net... > On Fri, 23 Sep 2011 05:23:38 -0400, Stephen Leake wrote: > >> "Dmitry A. Kazakov" writes: >> >>> Consider a generic >>> implementation of removing all elements of the container using >>> iterators: >>> >>> This := Container.First; >>> while This /= Null_Iterator loop >>> Next := This.Next; >>> This.Delete; >>> This := Next; >>> end loop; >>> >>> This may work or not depending on the semantics of Delete. E.g. for a >>> circular list, it will loop forever. >> >> No, it will produce an invalid dereference; for a one element circular >> list, This.Next = This, so Next is invalid after This.Delete. > > If the element is only in this list and freed upon delete, then Next is > dangling. > > However a common schema is that elements of lists are actually never > freed, > but rather moved to the list of unused element to reuse, when a new > element > is needed. For this implementation the above loops. In that case, the implementation of cursors is broken (IMHO) - dangling cursor detection should have been manditory, and surely should be in the case of element reuse. So Program_Error should be raised in either case, nothing erroneous or looping here. [Note that we are talking about containers, so I'm assuming that these things are cursors. If you are using raw access types in the user interface of any sort of container, you are living in the 1990s and are purposely destroying all of the real advantages of container usage.] Randy.