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.107.157.68 with SMTP id g65mr28944943ioe.22.1447610205798; Sun, 15 Nov 2015 09:56:45 -0800 (PST) X-Received: by 10.182.98.196 with SMTP id ek4mr284695obb.17.1447610205779; Sun, 15 Nov 2015 09:56:45 -0800 (PST) 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.glorb.com!i2no3606586igv.0!news-out.google.com!f6ni3427igq.0!nntp.google.com!i2no3114595igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 15 Nov 2015 09:56:45 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=68.145.219.148; posting-account=lzqe5AoAAADHhp_gregSufVhvwu22fBS NNTP-Posting-Host: 68.145.219.148 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <68087ee3-fc89-4c13-b5c4-3cd8984e9643@googlegroups.com> Subject: Re: A few questions From: Brad Moore Injection-Date: Sun, 15 Nov 2015 17:56:45 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:28368 Date: 2015-11-15T09:56:45-08:00 List-Id: On Thursday, November 12, 2015 at 2:08:54 PM UTC-7, Randy Brukardt wrote: > "Simon Wright" wrote in message=20 > 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 =3D> > >>> 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 =3D> 30)= ) > > > > (just in case) and as before got the 'expected a discrete type' error. >=20 > It should work either way. But does it work if you write: >=20 > for P in Prime_Number_Iterator.Forward_Iterator'Class=20 > (Prime_Number_Set'(Max_Value =3D> 30)) This doesn't work either >=20 > ?? If so, GNAT surely has a bug (the type conversion shouldn't change=20 > anything). You could also try: >=20 > for P in=20 > Prime_Number_Iterator.Forward_Iterator'(Prime_Number_Set'(Max_Value =3D> = 30)) This doesn't work also. However, if I declare the iterator as a declared object as in; Iterator : constant Prime_Number_Iterator.Forward_Iterator'Class :=3D Prime_Number_Set'(Max_Value =3D> 30); Then I can do this; for Prime in Iterator loop Put_Line (Integer'Image (Prime)); =20 end loop; However, if I declare it this way... Iterator : constant Prime_Number_Set :=3D Prime_Number_Set'(Max_Value =3D> 30); Then the loop above does not compile. So it seems to me that there are some GNAT bugs in this area. >=20 > which also shouldn't change anything. >=20 > > Perhaps this is a GNAT bug? >=20 > Looks like it to me. >=20 > > On the other hand, why did Brad include function Iterate? >=20 > It appears that he wanted tracing of the initialization (as that is all i= t=20 > does other than making a new iterator that is a copy of the first). It=20 > shouldn't be necessary. It's been a while since I wrote that example, and I'm not entirely sure why= I did it that way, but to be honest, I think I started with the existing c= ontainer iterators as my starting point example, which all have an Iterate = function, and I may have just assumed I needed a function which returned an= class-wide object. If the Prime Number Iterator is useful as an example for others, it would b= e nice to eliminate the Iterate function from the example. It seems also th= at there should be some more tests written to cover the failure cases that = we are discovering now. I'd be happy to update this ACATS test, if Randy th= inks its worthwhile. Brad