comp.lang.ada
 help / color / mirror / Atom feed
From: kst@king.cts.com (Keith Thompson)
Subject: Re: Ada Enumerations
Date: 1997/12/08
Date: 1997-12-08T00:00:00+00:00	[thread overview]
Message-ID: <881544004.778618@wagasa.cts.com> (raw)
In-Reply-To: dewar.881538896@merv


Robert Dewar (dewar@merv.cs.nyu.edu) wrote:
> Keith says
> 
> <<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.>>
> 
> The 'Valid attribute *is* usable for this purpose.

I should have been more specific.  At least one sensible usage of 'Valid
is not usable, given the current language definition.

Suppose an external interface provides integer values which are expected
to take on any of a specified set of values.  I declare an enumeration
type with a representation clause that matches the externally imposed
representation.  I then use Unchecked_Conversion to convert from the
integer type to my enumeration type.  Since I can't trust the external
interface 100%, I use 'Valid to check whether I have a valid value.

Unfortunately, RM95-13.9.1(12) says that a call to an instance of
Unchecked_Conversion is erroneous if the result is scalar and has an
invalid representation, so I get unpredictable behavior before I even
have a chance to use 'Valid.  I can work around this by wrapping the
scalar in a record, but I shouldn't have to.

It's true that most or all implementations will behave "sensibly" (as
the AARM vaguely encourages them to do), but I'd rather avoid erroneous
execution altogether than depend on this.

See also the minutes of the November ARG meeting in St. Louis.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <*>
^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
San Diego, California, USA
Trying to keep my daily caffeine intake between the RDA and the LD50.




  reply	other threads:[~1997-12-08  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       ` Ada Enumerations 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 Matthew Heaney
1997-12-04  0:00         ` Stanley R. Allen
1997-12-07  0:00           ` Keith Thompson
1997-12-07  0:00             ` Matthew Heaney
1997-12-07  0:00             ` Robert Dewar
1997-12-08  0:00               ` Keith Thompson [this message]
1997-12-07  0:00                 ` Matthew Heaney
1997-12-11  0:00                   ` John G. Volan
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-05  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   ` Stanley R. Allen
1997-12-12  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-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