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,ca9eef4d5e2078ea X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Re: Beware: Rep spec on an enumeration type causes code explosion Date: 1997/12/12 Message-ID: <3491E0BF.3D18@nospam.flash.net>#1/1 X-Deja-AN: 297711349 References: <348F3DFC.10DB@nospam.flash.net> <3490252D.6B550F17@ac3i.dseg.ti.com> <3490B7B1.711A@nospam.flash.net> Reply-To: Ken.Garlington@nospam.computer.org Organization: Flashnet Communications, http://www.flash.net Newsgroups: comp.lang.ada Date: 1997-12-12T00:00:00+00:00 List-Id: Matthew Heaney wrote: > > In article <3490B7B1.711A@nospam.flash.net>, > Ken.Garlington@nospam.computer.org wrote: > > >> Contiguous := Contiguous_Type (Holey); > >> -- implicitly does equivalent of 'Pos > > >This assumes Holey will always be one of A, B, C, D, E. What happens > >when the underlying > >I/O device returns a value of 6 for Holey? > > Of course, you must always check for validity prior to the conversion, > > if Holey'Valid then > Contiguous := Contiguous_Type (Holey); > else > > end if; which is the same as my original statement, to wit: "One of the nice things about 'holey' representations in Ada, when used for interfacing to external systems, is the use of 'Valid to check for valid input data in a very readable manner. However, I would convert the raw input to a non-holey type after the check, using either a map or case statement (depending upon the compiler)." A response to this statement was: "There is no need for anything so elaborate." The corresponding code did the conversion without a check, which prompted me to ask how validity was handled. > -------------------------------------------------------------------- > Matthew Heaney > Software Development Consultant > > (818) 985-1271