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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gegeweb.org!news.ecp.fr!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: A few questions Date: Thu, 12 Nov 2015 12:28:46 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1447352927 4773 24.196.82.226 (12 Nov 2015 18:28:47 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 12 Nov 2015 18:28:47 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:28324 Date: 2015-11-12T12:28:46-06:00 List-Id: wrote in message news:aa0cf839-651e-494d-a826-c2ce31a7afd3@googlegroups.com... >> The "of" form is for iterating over an array or a container whose type >> has >> the Default_Iterator aspect (which gives the iterator to use). > > The main drawback, though, is that you then get a Cursor, not an Element, > so > you still need to call the functions Element or Reference to get to the > actual > element. This is slightly less convenient (syntax-wise). Sure, but not in a case like the OP's, where the "cursor" is the actual data and there is no element. In that case, "of" is just overkill. > I wish it was possible > to use "of" to indicate that we want to get an element, even when the > right-side is an iterator (which for instance would be convenient when > writing graph data structures where there really are lots of different > ways > to iterate, and a single Default_Iterator is not enough That doesn't make sense, though, as the iterator interface doesn't contain the information necessary to do "of" iteration. In particular, it doesn't provide the container or Reference function -- nor could it, as there may not be a container. Personally, I find the "of" form unnecessary; we've iterated arrays for decades without direct access to the element (using the "cursor", that is the array index), so why are containers different? Especially as the indexing form works on all of the language-defined containers (you never need to explicitly call Reference or Element). So an "in" iterator looks just like the array iteration that we've been using from the beginning of time. What's so hard about that? Randy.