comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic, 561.796.8997, M/S 731-96" <condicma@PWFL.COM>
Subject: Re: Using the GNAT defined attribute: 'Enum_Rep
Date: 1997/09/09
Date: 1997-09-09T00:00:00+00:00	[thread overview]
Message-ID: <97090911205153@psavax.pwfl.com> (raw)


Robert A Duff <bobduff@WORLD.STD.COM> writes:
>In article <97082719523509@psavax.pwfl.com>,
>Marin David Condic, 561.796.8997, M/S 731-96 <condicma@PWFL.COM> 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
===============================================================================




             reply	other threads:[~1997-09-09  0:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-09  0:00 Marin David Condic, 561.796.8997, M/S 731-96 [this message]
1997-09-09  0:00 ` Using the GNAT defined attribute: 'Enum_Rep Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1997-09-09  0:00 Marin David Condic, 561.796.8997, M/S 731-96
1997-09-09  0:00 ` W. Wesley Groleau x4923
1997-09-11  0:00   ` Robert Dewar
1997-08-27  0:00 Marin David Condic, 561.796.8997, M/S 731-96
1997-09-03  0:00 ` W. Wesley Groleau x4923
1997-09-06  0:00   ` Robert Dewar
1997-09-08  0:00     ` Robert A Duff
1997-09-08  0:00     ` W. Wesley Groleau x4923
1997-09-08  0:00       ` Matthew Heaney
1997-09-08  0:00   ` Robert A Duff
1997-09-08  0:00     ` W. Wesley Groleau x4923
1997-09-08  0:00       ` Matthew Heaney
1997-09-09  0:00         ` Robert A Duff
1997-09-11  0:00           ` Robert Dewar
1997-09-08  0:00 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox