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: kst@king.cts.com (Keith Thompson) Subject: Re: Ada Enumerations Date: 1997/12/08 Message-ID: <881544004.778618@wagasa.cts.com>#1/1 X-Deja-AN: 296139987 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> Cache-Post-Path: wagasa.cts.com!kst@king.cts.com Organization: CTS Network Services Newsgroups: comp.lang.ada Date: 1997-12-08T00:00:00+00:00 List-Id: Robert Dewar (dewar@merv.cs.nyu.edu) wrote: > Keith says > > < 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.