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,68ab861309518ae8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-19 05:42:19 PST Path: supernews.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!lsanca1-snf1!news.gtei.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3ADECFD9.CBC57268@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: enumration using integers? References: <3ADEC4E8.954B6830@emw.ericsson.se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 19 Apr 2001 12:42:19 GMT NNTP-Posting-Host: 63.178.185.166 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 987684139 63.178.185.166 (Thu, 19 Apr 2001 05:42:19 PDT) NNTP-Posting-Date: Thu, 19 Apr 2001 05:42:19 PDT X-Received-Date: Thu, 19 Apr 2001 05:40:58 PDT (newsmaster1.prod.itd.earthlink.net) Xref: supernews.google.com comp.lang.ada:6995 Date: 2001-04-19T12:42:19+00:00 List-Id: Sven Nilsson wrote: > > Hello > > I have a little problem that I don't want to spend time solving... > > If I want to make an enumerated type using integers, like: > > type Distance is (10, 20, 30, 40, 50); > > The compiler will complain about missing identifiers. How do I get the > blasted machine to understand that the integers are the identifiers I > want? > Well, integers are not identifiers, and enumeration literals must be identifiers, so you cannot create an enumeration type whose literals are integers. Given a type definition like: type Distance is (Km_10, Km_20, Km_30, Km_40, Km_50); If you're using values of that type in registers or particular memory locations, as is commonly done in embedded programming, you can associate a representation specification with the type: for Distance use (Km_10 => 10, Km_20 => 20, Km_30 => 30, Km_40 => 40, Km_50 => 50); Or you can just use a little lookup table to get the value: type Distance_Values is array (Distance) of Natural; Dist : constant Distance_Values := (Km_10 => 10, Km_20 => 20, Km_30 => 30, Km_40 => 40, Km_50 => 50); Then just look up the value through the table: for D in Distance'Range loop Process(Dist(D)); end loop; Marc A. Criley Senior Staff Engineer Quadrus Corporation www.quadruscorp.com