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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ce37dd019a007e9a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-10 15:03:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn4feed!wn2feed!worldnet.att.net!204.127.198.204!attbi_feed4!attbi.com!rwcrnsc54.POSTED!not-for-mail From: "Mark Lundquist" Newsgroups: comp.lang.ada References: Subject: Re: Incompatible type error handling X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: NNTP-Posting-Host: e9bR7-32379-7y-13105@rwcrnsc54 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc54 1008025390 e9bR7-32379-7y-13105@rwcrnsc54 (Mon, 10 Dec 2001 23:03:10 GMT) NNTP-Posting-Date: Mon, 10 Dec 2001 23:03:10 GMT Organization: AT&T Broadband Date: Mon, 10 Dec 2001 23:03:10 GMT Xref: archiver1.google.com comp.lang.ada:17724 Date: 2001-12-10T23:03:10+00:00 List-Id: "Ben" wrote in message news:bf8dbe70.0112101352.20a3d257@posting.google.com... > Hi, > > I am new to Ada and the instruction book I found is not really helpful > in explaining how to handle errors of unmatching types. For example, > one of the sample problems the book has me do it a simple calculator > made to work with real values. Say I programmed it to work only with > integers, yet I enter a real number. That will cause a problem, > right? Probably so... at least, the calculator is not going to do what the user has in mind! Actually, this issue has nothing to do with "types" or type mismatch. You are not really entering any kind of a number, you're entering a string. The process of getting some kind of number from that is not one of "conversion" (as beginners often term it), but one of interpretation. Ada defines some elementary facilities that you can build on to do whatever interpretations you need; but these facilities necessarily only know about one type, and that is the type you are asking for. So if you type "123.456" into your calculator, Ada is not going to say "that's not an Integer, it's a Real Number", any more than if you typed "cow" it would say "that's not an Integer, it's an Animal". I mean, "12.10" could be real number, or it could be today's date, right? In your integer calculator, "3.14159" is not a real number, it is nonsense, and you'll have to program your calculator to recognize whatever you define to be nonsense and handle that nonsense in whatever way you think a calculator should handle it. > Is the error handling automatic in Ada, There's no error as far as Ada is concerned, only as far as your calculator is concerned. Hope this helps, -- mark