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 X-Google-Thread: 103376,32ba5f24e70f4e55 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-07 08:33:04 PST Path: newsfeed.google.com!newsfeed.stanford.edu!skynet.be!news1.ebone.net!news.ebone.net!newsfeeds.net.uni-c.dk!news.net.uni-c.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: accesing internal codes used for an enumeration Date: Mon, 07 May 2001 17:33:02 +0200 Organization: Centre for Chaos and Turbulence Studies, Niels Bohr Institute Message-ID: <3AF6C02E.2E40DB2A@nbi.dk> References: NNTP-Posting-Host: alf.nbi.dk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.net.uni-c.dk 989249583 34186 130.225.212.55 (7 May 2001 15:33:03 GMT) X-Complaints-To: usenet@news.net.uni-c.dk NNTP-Posting-Date: Mon, 7 May 2001 15:33:03 +0000 (UTC) X-Mailer: Mozilla 4.77 [en] (X11; U; OSF1 V4.0 alpha) X-Accept-Language: fo,da,no,sv,is,de,fr,en Xref: newsfeed.google.com comp.lang.ada:7264 Date: 2001-05-07T17:33:02+02:00 List-Id: Marius: > Implementation: > > type Names is (Ping, Pong); > for Names use (Ping => 123, Pong => 456); > > I found out the hardway that attribute Pos does not return the internal > code. It can be read from the LRM, although I think it could be formulated a bit clearer. > The ARM says this at 13.4(11), and tells you to use > Unchecked_Conversion instead--but does not instruct you on the types of > the conversion. Where might one learn that? Thanks. You should declare an integer type that is suitable for the mapping. An idea for the implementation: for Names'Size use 16; type Name_Indices is range 0 .. 2**16 - 1; for Name_Indices'Size use 16; function To_Index (Name : Names) return Name_Indices is new Ada.Unchecked_Conversion (Source => Names, Target => Name_Indices); Jacob -- "... det er ul�kkert, at man selektivt vil t�mme ulande/�steuropa for velkvalificerede mennesker." Christian Mikkelsen