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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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 p7mr11282396pbi.1.1316847394909; Fri, 23 Sep 2011 23:56:34 -0700 (PDT) Path: lh7ni3745pbb.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!feeder.news-service.com!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Sat, 24 Sep 2011 08:56:35 +0200 Organization: cbb software GmbH Message-ID: <19iim6m72b6s4$.qe1pwkufdkzn$.dlg@40tude.net> 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> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: eI5f/6w385de83NZyR/K4w.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news1.google.com comp.lang.ada:18110 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-09-24T08:56:35+02:00 List-Id: On Fri, 23 Sep 2011 17:42:39 -0500, Randy Brukardt wrote: > "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. Which does not invalidate my point about difficulties of generic programming with iterators, because the semantics of operations on iterators is ill defined. Whether accessing the iterator Next raised Program_Error or looped is no matter, so long it applies to a concrete container implementation. For generic programming you need Delete working in the same (specified) way for all container types of the set. Its effect on all iterators must be defined and same. My point and the purpose of the example was that this is extremely difficult to achieve, if possible. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de