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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!cornell!rochester!pt.cs.cmu.edu!sei!jbg From: jbg@sei.cmu.edu (John Goodenough) Newsgroups: comp.lang.ada Subject: Re: enumeration literal/internal codes query Message-ID: <8217@aw.sei.cmu.edu> Date: 15 Jan 89 04:42:46 GMT References: <1494@wayback.UUCP> <1499@wayback.UUCP> Organization: Carnegie-Mellon University (Software Engineering Institute), Pgh, PA In-reply-to: arny@wayback.UUCP's message of 10 Jan 89 23:15:41 GMT List-Id: In article Re: enumeration literal/internal codes query of 10 Jan 89 23:15:41 GMT arny@wayback.UUCP (Arny B. Engelson) writes: >> After specifying internal codes for the literals of an enumeration type >> using an enumeration representation clause, how do you (later in the >> code) find out what internal codes were specified? >'POS gives the position number, which always starts at 0 (RM 3.5.1), >and increments by 1 for each successor. This has NOTHING TO DO with >the internal codes specified in an enumeration representation clause. > >Also, I know Unchecked_Conversion can be used (by converting to an integer >type of the appropriate size), but this is extremely messy >(repeated instantiations for each enumeration type to be converted), and >not at all what I had in mind. There should be a better way. I know of no way other than Unchecked_Conversion to get at the actual internal codes. This has been remarked on a few times at language maintenance committee meetings. Robert Dewar (I think) has also pointed out that you can't access the internal representation of _any_ data type in the language. Even for integers, you only think you know the internal representation because it is so commonly a signed, unbiased representation, but if an implementation supports biased representation (e.g., when a record component is implemented with two bits because the component has the range 4..6), you can't detect the actual representation used any more than you can for enumeration literals. To argue that this is a language deficiency worthy of being corrected in the 9X revision, you need to describe the programming requirement for which this may be the correct solution, using the suggested revision request format. John B. Goodenough Goodenough@sei.cmu.edu Software Engineering Institute 412-268-6391