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/07 Message-ID: #1/1 X-Deja-AN: 296205653 References: <662cs9$b34$1@newman.pcisys.net> <663j9f$e1l@mtinsc02.worldnet.att.net> <3485D2AE.3F54@hso.link.com> <3487293E.794B@hso.link.com> <881531533.459982@wagasa.cts.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-12-07T00:00:00+00:00 List-Id: In article <881531533.459982@wagasa.cts.com>, kst@king.cts.com (Keith Thompson) wrote: >There are some partial solutions for these problems. Unchecked_Conversion >can be used to query the representation; the problem is determining an >integer type that matches a given enumeration type, especially if the >representation includes negative values. Why is this a problem? If you specify a representation, then you probably specified a size too, because you're transferring the data to an external device. So why not declare an instantiation of Unchecked_Conversion at the point of declaration of the enumeration type? type Color is (Red, Green, Blue); for Color use (Red => -2, Green => 5, Blue => 10); for Color'Size use 8; type Color_Rep is new Interfaces.Integer_8; function To_Rep is new Unchecked_Conversion (Color, Color_Rep); What's the problem? -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271