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: "Marin David Condic, 561.796.8997, M/S 731-96" Subject: Re: Using the GNAT defined attribute: 'Enum_Rep Date: 1997/09/09 Message-ID: <97090911205153@psavax.pwfl.com>#1/1 X-Deja-AN: 271037156 Sender: Ada programming language Comments: To: bobduff@world.std.com X-VMS-To: SMTP%"INFO-ADA@VM1.NODAK.EDU" X-VMS-Cc: SMTP%"bobduff@WORLD.STD.COM",CONDIC Newsgroups: comp.lang.ada Date: 1997-09-09T00:00:00+00:00 List-Id: Robert A Duff writes: >In article <97082719523509@psavax.pwfl.com>, >Marin David Condic, 561.796.8997, M/S 731-96 wrote: >> The ARM suggests using Unchecked_Conversion to get from here to >> there, but now you've got to create an integer type that is the >> same size as the enumerated type. Here's a code fragment: > >How about: > > type Temp_Integer is range 0..2**User_Types.CL_Evt_Status'Size; > >and use Temp_Integer'Base? Or: > > type Temp_Integer is mod User_Types.CL_Evt_Status'Size; > >? > That's pretty clever. Never thought of attempting to use the 'Size attribute in the type definition. I guess I had my brain wrapped around the axle with trying to use the 'Size attribute in the representation clause. Still, it would be very useful to have an attribute that is the inverse of 'Enum_Rep, taking a universal integer parameter and returning the corresponding enumeral - raising Constraint_Error if the integer did not match an enumeral internal representation. (Or possibly not raising the exception? Let it work a little like Unchecked_Conversion?) Thanks for the tip. MDC Marin David Condic, Senior Computer Engineer ATT: 561.796.8997 Pratt & Whitney GESP, M/S 731-96, P.O.B. 109600 Fax: 561.796.4669 West Palm Beach, FL, 33410-9600 Internet: CONDICMA@PWFL.COM =============================================================================== "There's a fine line between fishing and standing on the shore looking like an idiot." -- Steven Wright ===============================================================================