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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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 Received: by 10.68.33.71 with SMTP id p7mr3341187pbi.1.1316725415221; Thu, 22 Sep 2011 14:03:35 -0700 (PDT) Path: lh7ni2785pbb.0!nntp.google.com!news1.google.com!postnews.google.com!l4g2000vbz.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Thu, 22 Sep 2011 13:57:51 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <9f37b726-d80b-4d24-bf3f-28a14255f7fd@s20g2000yql.googlegroups.com> <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> NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 X-Trace: posting.google.com 1316725415 16313 127.0.0.1 (22 Sep 2011 21:03:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 22 Sep 2011 21:03:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l4g2000vbz.googlegroups.com; posting-host=83.3.40.82; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13,gzip(gfe) Xref: news1.google.com comp.lang.ada:18097 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-09-22T13:57:51-07:00 List-Id: On Sep 22, 10:07=A0am, "Dmitry A. Kazakov" wrote: > Consider a generic > implementation of removing all elements of the container using iterators: > > =A0 =A0This :=3D Container.First; > =A0 =A0while This /=3D Null_Iterator loop > =A0 =A0 =A0 =A0Next :=3D This.Next; > =A0 =A0 =A0 =A0This.Delete; > =A0 =A0 =A0 =A0This :=3D Next; > =A0 =A0end loop; > > This may work or not depending on the semantics of Delete. E.g. for a > circular list, it will loop forever. Not convincing, for several reasons: 1. Null_Iterator as a sentinel value is not necessary, you might use Container.Is_Empty instead. 2. Even with the above structure, This :=3D This.Delete_And_Move_To_Next would do the trick. It would also work for vectors. 3. You don't have to include circular lists in the same set of types as other linear containers in the first place, so there would be no temptation to use the generic algorithm with inappropriate container. That is, a circular list probably deserves a different interface anyway. 4. Are you sure that the circularity is a property of the container? Or rather of the traversal? Do you know that I can write a circular iterator as a wrapper for a "normal" one, for any linear container? Will you insist on having a completely separate container type for backwards/randomized/etc. iteration as well? So you are blaming iterators for having badly designed generic container interface in the first place. Not convincing. > Note that referential semantics has its place. My concern is its overuse > for things which don't require it, I agree here. But we still don't know whether iterators are bad. Because if they are good, then their referential semantics (if any) should be... forgiven? -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com