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!news.albasani.net!reality.xs3.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 15:08:52 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1447362533 18513 24.196.82.226 (12 Nov 2015 21:08:53 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 12 Nov 2015 21:08:53 +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:28339 Date: 2015-11-12T15:08:52-06:00 List-Id: "Simon Wright" wrote in message news:ly4mgrj8ab.fsf@pushface.org... > "Randy Brukardt" writes: > >> "Simon Wright" wrote in message >> news:lyziyskeu2.fsf@pushface.org... > >>> 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! > > Hmm. > > A Prime_Number_Set is a new Prime_Number_Iterator.Forward_Iterator; > Iterate returns a Prime_Number_Iterator.Forward_Iterator'Class. > > I tried without the .Iterate, as before, and with > > for P in Prime_Number_Set'Class (Prime_Number_Set'(Max_Value => 30)) > > (just in case) and as before got the 'expected a discrete type' error. It should work either way. But does it work if you write: for P in Prime_Number_Iterator.Forward_Iterator'Class (Prime_Number_Set'(Max_Value => 30)) ?? If so, GNAT surely has a bug (the type conversion shouldn't change anything). You could also try: for P in Prime_Number_Iterator.Forward_Iterator'(Prime_Number_Set'(Max_Value => 30)) which also shouldn't change anything. > Perhaps this is a GNAT bug? Looks like it to me. > On the other hand, why did Brad include function Iterate? It appears that he wanted tracing of the initialization (as that is all it does other than making a new iterator that is a copy of the first). It shouldn't be necessary. Randy.