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,b1a96e8174ef9f99 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-07 16:16:50 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!82-43-33-75.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: Need Value of enum type not position. Date: Sat, 08 Nov 2003 00:16:42 +0000 Message-ID: References: <686be06c.0311071027.79d6fa21@posting.google.com> <5sWdnUsWT9tqbDaiRVn-uw@comcast.com> NNTP-Posting-Host: 82-43-33-75.cable.ubr01.croy.blueyonder.co.uk (82.43.33.75) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1068250609 47901809 82.43.33.75 (16 [25716]) User-Agent: Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en In-Reply-To: <5sWdnUsWT9tqbDaiRVn-uw@comcast.com> Xref: archiver1.google.com comp.lang.ada:2245 Date: 2003-11-08T00:16:42+00:00 List-Id: A possible alternative approach, not necessarily any better than using Unchecked_Conversion, is to use a constant lookup array: type Hov_Mode_Type is (INVALID, OFF, INITIATE, AUTO); Hov_Mode_Code: constant array (Hov_Mode_Type) of Integer := (INVALID => 7, OFF => 8, INITIATE => 9, AUTO => 10); Depending on other factors (you have not mentioned), it may or may not be necessary for you to also have the enumeration representation clause. One advantage of this technique is that it may make the logic of a certain part of your code immune to changes in representation (encoding) which might perhaps be required during the maintenance or update of another part of your code (or hardware). Obviously, this separation could turn out to be a disadvantage, depending on the logic of your code. A disadvantage is that the lookup array is likely (but not certain) to be implemented as an actual array in memory. If the speed of obtaining a code is critical, this might matter (but I think it's unlikely). This sort of array can have cache-clobbering properties, which can be unfortunate from a speed point of view (but not in any other way). -- Nick Roberts