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,436ac666600e5ab3 X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: Exception Handling Date: 2000/06/01 Message-ID: <3936E41C.FCDE89D6@acm.org>#1/1 X-Deja-AN: 630025633 Content-Transfer-Encoding: 7bit References: <3HCY4.29157$sB3.10828@news.indigo.ie> <3933DAF3.35F40B3A@utech.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 959902266 63.10.52.39 (Thu, 01 Jun 2000 16:31:06 PDT) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 Reply-To: jrcarter@acm.org NNTP-Posting-Date: Thu, 01 Jun 2000 16:31:06 PDT Newsgroups: comp.lang.ada Date: 2000-06-01T00:00:00+00:00 List-Id: Preben Randhol wrote: > One slightly different angle though. Say you have made a program that > expects the user to input a value. It could be any value so it should be > possible to enter 2.3E-4 etc... > > Would it be OK to trap an erronious entry (like "2.3W-4") with an > exception or would you make an extra check before trying to convert the > string to a float (or the appropriate class). Ada provides at least 2 ways to check that a string contains an appropriate representation of a floating-point number: 'Value and Ada.Text_IO.Float_IO. Both convert the string to a floating-point value and signal an invalid string by raising an exception. Whether you agree that raising an exception is appropriate, why would you write another subprogram to parse a string for a floating-point value when you can reuse these existing, robust, and well-tested subprograms? -- Jeff Carter "Now go away or I shall taunt you a second time." Monty Python & the Holy Grail