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,2193caf6800acc13 X-Google-Attributes: gid103376,public From: kst@thomsoft.com (Keith Thompson) Subject: Re: Ada for Data Processing? Date: 1996/10/05 Message-ID: #1/1 X-Deja-AN: 187723953 sender: news@thomsoft.com (USENET News Admin @flash) x-nntp-posting-host: pulsar references: <52to6o$6p2@news1.mnsinc.com> <32546043.1BF3@dynamite.com.au> organization: Thomson Software Products, San Diego, CA, USA newsgroups: comp.lang.ada originator: kst@pulsar Date: 1996-10-05T00:00:00+00:00 List-Id: In <32546043.1BF3@dynamite.com.au> Alan Brain writes: [...] > Type TRAFFIC_LIGHT_TYPE is (Red, Yellow, Green); > Type REPRESENTED_TRAFFIC_LIGHT_TYPE is new TRAFFIC_LIGHT_TYPE; > for REPRESENTED_TRAFFIC_LIGHT_TYPE'SIZE use 16; > for REPRESENTED_TRAFFIC_LIGHT_TYPE use > ( RED => 16#FE00, YELLOW => 16#00FF, GREEN => 16#EE77); The values given in an enumeration representation clause must satisfy the predefined ordering relationship of the type (RM95-13.4(6)). > TARGET : TRAFFIC_LIGHT_TYPE; > SOURCE : REPRESENTED_TRAFFIC_LIGHT_TYPE; > > begin > > -- do the unchecked conversion to SOURCE here -- > -- .. > > PARANOIA_BLOCK: > > begin > TARGET := TRAFFIC_LIGHT_TYPE(SOURCE); > exception > when CONSTRAINT_ERROR => -- your data is definitely bad > -- etc > end PARANOIA_BLOCK; > > .. > end If Source contains an invalid value, I don't think there's any guarantee that the conversion will raise Constraint_Error. In fact, one could argue that Program_Error makes more sense (assuming the error is detected at all). -- Keith Thompson (The_Other_Keith) kst@thomsoft.com <*> TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706 FIJAGDWOL