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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: Alan Brain Subject: Re: Ada for Data Processing? Date: 1996/10/11 Message-ID: <325DF8CA.56A4@dynamite.com.au>#1/1 X-Deja-AN: 188589037 references: <52to6o$6p2@news1.mnsinc.com> <32546043.1BF3@dynamite.com.au> content-type: text/plain; charset=us-ascii organization: @Home mime-version: 1.0 reply-to: aebrain@dynamite.com.au newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win16; I) Date: 1996-10-11T00:00:00+00:00 List-Id: Keith Thompson wrote: > > In <32546043.1BF3@dynamite.com.au> Alan Brain writes: > > 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)). ..which is what I get for not compiling my code fragments before sending. Ta for spotting this. I really should have seen it myself, it's one of my more common coding errors found in the 1st pass. > > 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). Why? How is this different from any other checked conversion? I see your point about Program_Error, but would hate to be the guy writing the compiler code to produce this. But a Constraint_Error is reasonable; and to write a compiler so as not to do such a check in this instance would be more work than leaving the check in. I don't have my LRM handy, but can you see how the wording re Constraint_Error would not apply here? I can't. ---------------------- <> <> How doth the little Crocodile | Alan & Carmel Brain| xxxxx Improve his shining tail? | Canberra Australia | xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM ---------------------- o OO*O^^^^O*OO o oo oo oo oo By pulling Maerklin Wagons, in 1/220 Scale