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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.43.198 with SMTP id u64mr1934054ota.32.1465371064727; Wed, 08 Jun 2016 00:31:04 -0700 (PDT) X-Received: by 10.157.14.228 with SMTP id 91mr329482otj.11.1465371064535; Wed, 08 Jun 2016 00:31:04 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!p34no4091310qgp.1!news-out.google.com!107ni233qgx.1!nntp.google.com!q32no5110994qgq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 8 Jun 2016 00:31:04 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:2ab8:224:1:3943:5ece:7e0:f73b; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH NNTP-Posting-Host: 2a02:2ab8:224:1:3943:5ece:7e0:f73b References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7d9aaa87-1dd2-4432-a958-aaa98125a01f@googlegroups.com> Subject: Re: Traits and iterators (was: Mixing operators and dot notation) From: briot.emmanuel@gmail.com Injection-Date: Wed, 08 Jun 2016 07:31:04 +0000 Content-Type: text/plain; charset=UTF-8 X-Received-Bytes: 2538 X-Received-Body-CRC: 3303671665 Xref: news.eternal-september.org comp.lang.ada:30658 Date: 2016-06-08T00:31:04-07:00 List-Id: > generic > with package Elements is new Elements_Policy (<>); > type Container is private; > type Cursor is private; > with function First (Self : Container) return Cursor is <>; > with function Has_Element > (Self : Container; C : Cursor) return Boolean is <>; > with function Element (C : Cursor) return Elements.Element is <>; > with procedure Next (C : in out Cursor) is <>; > package Forward_Cursors_Policy is > end Forward_Cursors_Policy; > > That, in itself, I don't think will give the ability to use "of" in > iterations, although it enables one to iterate over an unknown type. Indeed, this signature package allows you to write an explicit iteration loop, where you manipulate cursors explicitly. I don't know, and I don't think it is doable, how to pass a formal type and mention that it should be iterable in the sense of the "for..of" loop. That means that any generic algorithm we write will take the above Policy package, but will not be able to use "for..of". That's a bit more work to write, but just as efficient in the end, but perhaps a limitation in the language.