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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,32ba5f24e70f4e55 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-07 08:54:58 PST Path: newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: Subject: Re: accesing internal codes used for an enumeration Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Mon, 07 May 2001 11:54:28 EDT Organization: http://www.newsranger.com Date: Mon, 07 May 2001 15:54:28 GMT Xref: newsfeed.google.com comp.lang.ada:7267 Date: 2001-05-07T15:54:28+00:00 List-Id: In article , Marius Amado Alves says... > >I am trying to implement a lexicon (in the database sense) as an >enumeration with a representation clause. > >Example lexicon: > > Name <-> Code > ------------- > Ping 123 > Pong 456 > >Implementation: > > type Names is (Ping, Pong); > for Names use (Ping => 123, Pong => 456); What this does is tell the compiler to use 123 as the actual bit pattern that represents "Ping" when it is stored in memory (or perhaps on disk). There is no way to get at that value, short of converting it to something else in an "unchecked" manner. If all you want to do is make force a specific bit pattern on those objects when they are stored, then this is the way to do it. If instead you just want a mapping that you can use internally in your program, you would probably be better off doing something like the following: type Names is (Ping, Pong); type Name_Integer_Mapping is array (Names) of Integer; Name_Map : constant Name_Integer_Mapping := (Ping => 123, Pong => 456); --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com