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,514627f9964b6e38 X-Google-Attributes: gid103376,public From: "W. Wesley Groleau x4923" Subject: Re: Using the GNAT defined attribute: 'Enum_Rep Date: 1997/09/03 Message-ID: <340D6C5D.2E53@pseserv3.fw.hac.com>#1/1 X-Deja-AN: 269709641 Sender: usenet@most.fw.hac.com (News Administration) X-Nntp-Posting-Host: sparc02 References: <97082719523509@psavax.pwfl.com> To: "Marin David Condic, 561.796.8997, M/S 731-96" Organization: Hughes Defense Communications Newsgroups: comp.lang.ada Date: 1997-09-03T00:00:00+00:00 List-Id: > Here's a little problem which I could use some help handling: > > .... to create an integer type that is the > same size as the enumerated type. Here's a code fragment: > > type Temp_Integer is range Integer'First..Integer'Last ; > for Temp_Integer'Size use User_Types.CL_Evt_Status'Size ; > --^^^^^^^^^^^^^^^^^^^^^^ The enumerated type. > > .... new Ada.Unchecked_Conversion ( > Source => Temp_Integer ; > Target => User_Types.CL_Evt_Status) ; you've probably already discovered that Integer'First..Integer'Last forces a minimum on Temp_Integer'Size. And in Ada 83, the above would not be legal because 'Size is _defined_ as non-static, thus can't be used to specify another 'Size. To get around this, I did CL_Evt_Status_Size : constant := ######; for CL_Evt_Status'Size use CL_Evt_Status_Size; Now CL_Evt_Status_Size can be used anywhere that CL_Evt_Status'Size can be used, and it will be static. > 'Pos and 'Val. ... will work If and only if the representation is > identical to the position numbers - what you get if you don't > specify a representation. .... Is this true ? Seems to me it's legal (though I've never seen it happen) for an implementation to generate anything it wanted for a representation as long as ordering, indexing, etc. worked. I can imagine a CPU where a bit per value is more efficient, i.e., an implicit for Enum use ( 0, 1, 2, 4, 8, 16, 32, ... ); though, again, I've never seen that done. -- ---------------------------------------------------------------------- Wes Groleau, Hughes Defense Communications, Fort Wayne, IN USA Senior Software Engineer - AFATDS Tool-smith Wanna-be wwgrol AT pseserv3.fw.hac.com Don't send advertisements to this domain unless asked! All disk space on fw.hac.com hosts belongs to either Hughes Defense Communications or the United States government. Using email to store YOUR advertising on them is trespassing! ----------------------------------------------------------------------