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.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3c55100a141db64d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1993-03-22 07:48:37 PST Path: sparky!uunet!munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!usenet From: andrewd@eeyore.cs.adelaide.edu.au (Andrew Dunstan,,2285592,) Newsgroups: comp.lang.ada Subject: Re: Membership in "set" of characters Date: 22 Mar 1993 10:37:48 GMT Organization: The University of Adelaide Message-ID: <1ok4ts$3cv@huon.itd.adelaide.edu.au> References: <1993Mar19.195712.9187@wdl.loral.com> Reply-To: andrewd@cs.adelaide.edu.au NNTP-Posting-Host: eeyore.cs.adelaide.edu.au Date: 1993-03-22T10:37:48+00:00 List-Id: >From article <1993Mar19.195712.9187@wdl.loral.com>, by mab@wdl39.wdl.loral.com (Mark A Biggar): > In article dww@math.fu-berlin.de (Debora Weber-Wulff) writes: >>with text_io; use text_io; >>procedure muell3 is >>type affirmatives is ('y', 'Y', 'j', 'J', 'o', 'O'); >> ch : CHARACTER; >> okay : Boolean; >>begin >> get (ch); >> -- The next statement gets flagged with >> -- type clash in membership test [LRM 4.5.2/10] >> okay := ch IN affirmatives; >>end muell3; > > The error message from the compiler is correct type CHARACTER clashes with > type affirmatives. The only way to do what you want is to cheat using 'value > and 'image like so > The 'character' literals are not characters, but the (overloaded) names of the values of an enumeration type. That is why there is a type clash. Better still, let's ask WHY you want to do this. Are the affirmatives the only valid responses? If so, then use enumeration_io and trap the exception data_error. If not, if any character value will do, use the approach already suggested by Mark. If the range of valid responses is more limited, decalre an enumeration type with all the affirmative responses at one end and the rest at the other end, and then declare affirmative as a subrange of valid_responses. then get your response (using enumeration_io and check to see if it is in the subrange. cheers andrew dunstan. ####################################################################### # Andrew Dunstan # There's nothing good or bad # # Department of Computer Science # but thinking makes it so. # # University of Adelaide # #