From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a415d3a613d86a4e X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Ada Enumerations Date: 1997/12/07 Message-ID: #1/1 X-Deja-AN: 296205652 References: <662cs9$b34$1@newman.pcisys.net> <663j9f$e1l@mtinsc02.worldnet.att.net> <3485D2AE.3F54@hso.link.com> <3487293E.794B@hso.link.com> <881531533.459982@wagasa.cts.com> <881544004.778618@wagasa.cts.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-12-07T00:00:00+00:00 List-Id: 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 (818) 985-1271