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-Thread: 103376,4f1451304206fe77 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: Accessing the underlying rep for enumerated types? Date: Wed, 13 Oct 2004 22:49:46 +0100 Message-ID: <2t5m7qF1s74tnU1@uni-berlin.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de kzcq0e2laCKNJFhE1NhTbwIsb+KxM/l98OHaLGfg8cpVFwNOc= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:5182 Date: 2004-10-13T22:49:46+01:00 List-Id: Dale Stanbrough wrote: > .... Yes, me too. The answers to Dale's question seem to have been a little less than courteous and sympathetic. > Obviously I have to phrase this much more pedantically. > > Is there any feature in the language that allows me to get access > to the underlying enumeration values other than using Unchecked > Conversion? I think the answer is "No", there is no such feature in the language. Obviously any use of Unchecked_Conversion is theoretically non-portable, and so, indeed, is any attempt to specify the representation of an enumerated type. On the other hand, I suspect that using Unchecked_Conversion to convert to a modular type of the right size is likely to work on most implementations (perhaps all that don't reject it). I've tested this with GNAT 3.15p (it works). Writing out a value of the enumerated type to a stream, and then reading it back into an object of a modular type (of the right size) might also work. Some implementations might provide an attribute which returns the underlying value. I admit, I'm not aware of any. -- Nick Roberts