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!gandalf.srv.welterde.de!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:32:09 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1447353130 4819 24.196.82.226 (12 Nov 2015 18:32:10 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 12 Nov 2015 18:32:10 +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:28326 Date: 2015-11-12T12:32:09-06:00 List-Id: "Simon Wright" wrote in message news:lyziyskeu2.fsf@pushface.org... > Simon Wright writes: > >> "Randy Brukardt" writes: >> >>> Prime_Number_Set is (directly) an iterator, so you use "in" to iterate >>> over it: >>> >>> for P in F552A00_Prime_Numbers.Prime_Number_Set'(Max_Value => 31) loop >>> >>> 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). >>> >>> I can hear the head slap from here. ;-) >> >> Yes, but; >> >> 1. with Ada.Text_IO; >> 2. with F552A00_Prime_Numbers; >> 3. procedure Primes is >> 4. begin >> 5. for P in F552A00_Prime_Numbers.Prime_Number_Set'(Max_Value => >> 31) loop >> | >> >>> expected a discrete type >> >>> found type "Prime_Number_Set" defined at >> >>> f552a00_prime_numbers.ads:74 >> >> 6. Ada.Text_IO.Put_Line (P'Img); >> 7. end loop; >> 8. end Primes; >> >> Perhaps this is the GNAT problem you spoke of? (FSF GCC 5.1.0, GNAT GPL >> 2015) > > Oh, it should have been > > for P in F552A00_Prime_Numbers.Prime_Number_Set'(Max_Value => > 31).Iterate > loop I probably would have made type Prime_Number_Set directly the iterator type (I don't see any other need for it), which would get rid of the need for the ".Iterate". An iterator doesn't necessarily have to have anything to do with a container! Randy.