comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Ada Enumerations
Date: 1997/12/07
Date: 1997-12-07T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680000712972302290001@news.ni.net> (raw)
In-Reply-To: 881544004.778618@wagasa.cts.com


In article <881544004.778618@wagasa.cts.com>, kst@king.cts.com (Keith
Thompson) wrote:


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

This is what I was alluding to when I said that it's often the case that an
integer is prefered over an enumeration.  Instead of

1) read value into integer
2) convert integer to enumeration
3) check that enumeration is valid

I prefer to avoid the potential erroneousness of step 2  by doing this

1) read value into integer
2) check that integer has an acceptable value
3) convert integer to enumeration

I don't disagree that 13.9.1 (12) is an issue, but the validity check and
type conversion should be hidden inside an interface object anyway, so
what's the big deal about checking the value manually?

Furthermore, I don't understand why you even bothered reading into an
integer.  Why not just read into an enumeration type directly?  How about

1) read value into enumeration object
2) check validity

Now no conversion is required at all, and 13.9.1 (12) doesn't even come up.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




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