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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a415d3a613d86a4e X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Ada Enumerations Date: 1997/12/04 Message-ID: #1/1 X-Deja-AN: 295200271 References: <662cs9$b34$1@newman.pcisys.net> <663j9f$e1l@mtinsc02.worldnet.att.net> <3485D2AE.3F54@hso.link.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-12-04T00:00:00+00:00 List-Id: In article <3485D2AE.3F54@hso.link.com>, "Stanley R. Allen" wrote: >> If you are using GNAT, you can use the 'Enum_Rep attribute to get the >> representation value for an enumeration literal. This seems a generally >> useful attribute, it would be nice if other Ada 95 compilers would >> implement it. >> > >Hear, Hear! I was surprised that Ada95 didn't correct this obvious >deficiency in Ada83. Personally, I feel that if you're always looking at the rep of the enumerands, then you probably don't want an enumeration type anyway. That being said, why don't you just perform an instantiation of UC at the point of declaration of the type? with Unchecked_Conversion, Interfaces; package Color_Types is type Color is (Red, Green, Blue); for Color use (Red => 2, Green => 5, Blue => 8); for Color'Size use 8; function To_Rep is new Unchecked_Conversion (Color, Interfaces.Unsigned_8); end Color_Types; What's the big deal? It's only 1 extra declaration (the instantiation of UC). -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271