comp.lang.ada
 help / color / mirror / Atom feed
From: "W. Wesley Groleau x4923" <wwgrol@pseserv3.fw.hac.com>
To: "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/03
Date: 1997-09-03T00:00:00+00:00	[thread overview]
Message-ID: <340D6C5D.2E53@pseserv3.fw.hac.com> (raw)
In-Reply-To: 97082719523509@psavax.pwfl.com



>     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!
----------------------------------------------------------------------




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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-27  0:00 Using the GNAT defined attribute: 'Enum_Rep Marin David Condic, 561.796.8997, M/S 731-96
1997-09-03  0:00 ` W. Wesley Groleau x4923 [this message]
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
  -- 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-09-09  0:00 Marin David Condic, 561.796.8997, M/S 731-96
1997-09-09  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