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.52.10 with SMTP id p10mr825990pbo.17.1316638391980; Wed, 21 Sep 2011 13:53:11 -0700 (PDT) Path: lh7ni2077pbb.0!nntp.google.com!news1.google.com!postnews.google.com!g30g2000yqc.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Wed, 21 Sep 2011 13:51:43 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <9f37b726-d80b-4d24-bf3f-28a14255f7fd@s20g2000yql.googlegroups.com> <0d272f62-67d0-4905-972c-8a7e912c5531@en1g2000vbb.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> NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 X-Trace: posting.google.com 1316638391 17239 127.0.0.1 (21 Sep 2011 20:53:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 21 Sep 2011 20:53:11 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g30g2000yqc.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:18070 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-09-21T13:51:43-07:00 List-Id: On Sep 21, 9:48=A0am, "Dmitry A. Kazakov" wrote: > > Nobody is forcing referential semantics, although it might be the most > > natural and efficient solution for iterators. > > Of course it does, because the iterator refers to the container and to an > element in that container. Not necessarily. Think about a map. Let's say a map with strings as keys. We can say that strings are associated with values in the map and that strings allow to obtain those values. But can we say that strings refer to those elements? Or that they point to them? I don't think most programmers would think about the role of some string in the map this way. So let's define the iterator as an entity that is associated with the element in a container and that allows to obtain that element. Depending on the capability of the iterator, it might also allow traversal, but that does not change much. The point is - at a high level, there is no need to think about iterators as having any referential semantics. A pointer value is an easy choice at the implementation level, but it does not have to be visible at the high level. So - no referential semantics is needed to define iterators. > Which is evidently fragile as any reference when > the container and its element mutate. That is, the validity of an iterator is tied to the mutability of the container. It is fragile in the same way as array indices, since they become invalid when the array is reorganized. Or database keys. Or file names. Or phone numbers. > It is also bad for generic > programming, because the semantics of the side-effects depends on the > implementation, i.e. the internal structure of the container. Not convincing - generics are supposed to have well defined specs. If you worry about your side effects being bound to implementation, then there is something wrong with your model of generics. Don't blame iterators for this. I consider iterators to be very useful and you have not convinced me that they are evil. -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com