From: Nick Roberts <nick.roberts@acm.org>
Subject: Re: Accessing the underlying rep for enumerated types?
Date: Wed, 13 Oct 2004 22:49:46 +0100
Date: 2004-10-13T22:49:46+01:00 [thread overview]
Message-ID: <2t5m7qF1s74tnU1@uni-berlin.de> (raw)
In-Reply-To: <MrNoSpam-CCC41B.16510613102004@news-server.bigpond.net.au>
Dale Stanbrough wrote:
> <sigh>....
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
next prev parent reply other threads:[~2004-10-13 21:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-12 22:32 Accessing the underlying rep for enumerated types? Dale Stanbrough
2004-10-13 0:20 ` Stephen Leake
[not found] ` <MrNoSpam-2408AC.16521913102004@news-server.bigpond.net.au>
2004-10-13 7:23 ` Marius Amado Alves
2004-10-13 12:29 ` Stephen Leake
2004-10-13 1:26 ` Jeffrey Carter
2004-10-13 6:51 ` Dale Stanbrough
2004-10-13 21:49 ` Nick Roberts [this message]
2004-10-14 1:25 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox