comp.lang.ada
 help / color / mirror / Atom feed
From: kst@king.cts.com (Keith Thompson)
Subject: Re: Ada Enumerations
Date: 1997/12/07
Date: 1997-12-07T00:00:00+00:00	[thread overview]
Message-ID: <881531533.459982@wagasa.cts.com> (raw)
In-Reply-To: 3487293E.794B@hso.link.com


Stanley R. Allen (s_allen@hso.link.com) wrote:
> Matthew Heaney wrote:
> > Personally, I feel that if you're always looking at the rep of the
> > enumerands, then you probably don't want an enumeration type anyway.
> 
> That's a dead argument on the face of it.  If the language
> permits me to *specify* the representation, then why doesn't
> it permit me to *query* the specified values?

Because, IMHO, enumeration representation clauses weren't thought out as
well as they should have been when Ada 83 was designed, and the problems
weren't corrected in the Ada 95 revision.  If the language had defined
attributes to convert between an enumeration type and Universal_Integer,
analogous to 'Val and 'Pos but using the underlying representation rather
than the position value, along with a good way to determine whether
an enumeration value from an external source is valid, enumeration
representation clauses would have been much more useful.

There are some partial solutions for these problems.  Unchecked_Conversion
can be used to query the representation; the problem is determining an
integer type that matches a given enumeration type, especially if the
representation includes negative values.  GNAT provides the 'Enum_Rep
attribute (but not 'Enum_Val), but it's not portable.  The 'Valid
attribute should be usable to validate external data, but straightforward
use of it is erroneous by RM95-13.9.1; see also AI95-00167.





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

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-12-03  0:00 Ada Enumerations Jeffrey Harris
1997-12-03  0:00 ` James S. Rogers
1997-12-03  0:00   ` Robert Dewar
1997-12-03  0:00     ` Stanley R. Allen
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-08  0:00         ` GNAT'Object_Size Mats Weber
1997-12-10  0:00           ` GNAT'Object_Size Robert Dewar
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-05  0:00         ` GNAT'Object_Size Mats Weber
1997-12-04  0:00       ` Ada Enumerations Matthew Heaney
1997-12-04  0:00         ` Stanley R. Allen
1997-12-07  0:00           ` Keith Thompson [this message]
1997-12-07  0:00             ` Robert Dewar
1997-12-08  0:00               ` Keith Thompson
1997-12-07  0:00                 ` Matthew Heaney
1997-12-11  0:00                   ` John G. Volan
1997-12-07  0:00             ` Matthew Heaney
1997-12-04  0:00       ` Robert Dewar
1997-12-04  0:00         ` Stanley R. Allen
1997-12-18  0:00           ` Wes Groleau
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-04  0:00 ` Ada Enumerations Stephen Leake
1997-12-04  0:00   ` Matthew Heaney
1997-12-04  0:00     ` Robert Dewar
1997-12-06  0:00       ` Jean-Pierre Rosen
1997-12-06  0:00         ` Making Predefined Operators Abstract Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
1997-12-10  0:00 Ada enumerations Stanley R. Allen
1997-12-10  0:00 ` Robert Dewar
1997-12-11  0:00   ` Mats Weber
1997-12-11  0:00     ` Robert Dewar
1997-12-12  0:00       ` Mats Weber
1997-12-12  0:00         ` Robert Dewar
1997-12-12  0:00     ` Samuel T. Harris
1997-12-11  0:00   ` Stanley R. Allen
1997-12-12  0:00     ` Robert Dewar
1997-12-10  0:00 ` John M. Mills
replies disabled

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