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.33.71 with SMTP id p7mr11899135pbi.1.1316861229039; Sat, 24 Sep 2011 03:47:09 -0700 (PDT) Path: lh7ni3858pbb.0!nntp.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: discriminant questions 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> Date: Sat, 24 Sep 2011 06:47:10 -0400 Message-ID: <82ty82dxox.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (windows-nt) Cancel-Lock: sha1:M5f6TS6yAftUM6/2YC00I+MINp8= MIME-Version: 1.0 X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: a25ca4e7db52ce029e66128416 Xref: news1.google.com comp.lang.ada:18111 Content-Type: text/plain; charset=us-ascii Date: 2011-09-24T06:47:10-04:00 List-Id: "Randy Brukardt" writes: > "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.] +1 -- -- Stephe