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 2002:a02:81:: with SMTP id 123mr4548667jaa.17.1548317210908; Thu, 24 Jan 2019 00:06:50 -0800 (PST) X-Received: by 2002:aca:cc0f:: with SMTP id c15mr16838oig.3.1548317209324; Thu, 24 Jan 2019 00:06:49 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!2.eu.feeder.erje.net!4.us.feeder.erje.net!feeder.erje.net!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!q69no103769itb.0!news-out.google.com!v71ni151ita.0!nntp.google.com!k10no103214itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 24 Jan 2019 00:06:49 -0800 (PST) In-Reply-To: <217206e7-81aa-4aa8-8d19-66498c36100d@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2003:c7:83db:8df6:4af:234d:34f1:3409; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 2003:c7:83db:8df6:4af:234d:34f1:3409 References: <3d782720-227d-4d86-b403-eacbd1b9d0d2@googlegroups.com> <72fd7f46-21bb-45b9-9621-237bca776378@googlegroups.com> <217206e7-81aa-4aa8-8d19-66498c36100d@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <959429b8-2817-4339-bd01-01153a7a544c@googlegroups.com> Subject: Re: Problem with Position of the enumeration Type From: AdaMagica Injection-Date: Thu, 24 Jan 2019 08:06:50 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:55356 Date: 2019-01-24T00:06:49-08:00 List-Id: Am Mittwoch, 23. Januar 2019 13:08:34 UTC+1 schrieb Luis Ladron de Guevara = Moreno: > El mi=C3=A9rcoles, 23 de enero de 2019, 11:33:36 (UTC+1), AdaMagica escr= ibi=C3=B3: > > See RM 13.4(11/3)ff: > > NOTES > > 14 Unchecked_Conversion may be used to query the internal codes used fo= r > > an enumeration type. The attributes of the type, such as Succ, Pred, an= d Pos, are unaffected by the enumeration_representation_clauserepresentatio= n_clause. > >=20 > > Some questions on your code: > >=20 > > Position : Integer; -- Why is this Integer and not Natural? > > =20 > > for I in E_Test'Base loop -- Why do you use 'Base here? >=20 > I wrote a Integer as an example, i could add Natural also, for this examp= le there are not difference. It does make a difference. Ada has subtypes just for this purpose: If you k= now that the values of an object of some type belong only to some subtype, = you indicate this in the declaration. This is the very idea of stong typing. > I'm using 'Range to go through all the positions in enumeration. No, you used 'Base. For a enum type E, these are always the same: for V in E loop for V in E'Range loop For an enum type that is not derived, E'Base is the same as E. For types de= rived from E, there might be a difference. > I tried to use Ada.Unchecked_Conversion and i got obtain the values for t= he position. but as you told me, if i use 'post (), the number of the list = start in 0. Yes, this is what the RM prescribes.