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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,269df2c167555fd6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-23 05:26:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out.usenetserver.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3A9656F2.78E31E61@earthlink.net> From: "Marc A. Criley" Organization: Quadrus Corporation X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Representation clause References: <3a95c52f@post.usenet.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 23 Feb 2001 13:25:19 GMT NNTP-Posting-Host: 158.252.122.229 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 982934719 158.252.122.229 (Fri, 23 Feb 2001 05:25:19 PST) NNTP-Posting-Date: Fri, 23 Feb 2001 05:25:19 PST Xref: supernews.google.com comp.lang.ada:5468 Date: 2001-02-23T13:25:19+00:00 List-Id: Anatoly Chernyshev wrote: > > Now I wander about representation clause for enumerated types. > For example, > type ATOM is (H, C, N, O); > for ATOM use (H=>1, C=>6, N=>7, O=>8); > > How can I access these 'internal' numbers? > ATOM'POS yields 0, 1, 2, 3 respectively and I know no other relevant > attributes. > If you're using GNAT and don't mind using a compiler-specific attribute, GNAT supplies one called Enum_Rep that will extract values specified by a representation clause. with Text_IO; use Text_IO; procedure Cer is type ATOM is (H, C, N, O); for ATOM use (H=>1, C=>6, N=>7, O=>8); begin Put_Line(Integer'Image(Atom'Enum_Rep(N))); end Cer; Ouputs: 7 Marc A. Criley Senior Staff Engineer Quadrus Corporation www.quadruscorp.com