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,ea2b3498720dfde1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-26 14:11:57 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!207.217.77.102!newsfeed2.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3DBB0508.6010707@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Good Ada Style For Impossible Actions? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 26 Oct 2002 21:11:07 GMT NNTP-Posting-Host: 63.184.17.201 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1035666667 63.184.17.201 (Sat, 26 Oct 2002 14:11:07 PDT) NNTP-Posting-Date: Sat, 26 Oct 2002 14:11:07 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:30160 Date: 2002-10-26T21:11:07+00:00 List-Id: Dr Nancy's Sweetie wrote: > Considering the parallel with reading input, I could write two functions, > a "Display.Within_Active_Window", returning a Boolean, and then put the > call to Display.Translate_Mouse_Event inside an "if" (following the example > of Ada's "End_Of_File" function, which you call before calling "Get", > instead of calling Get and seeing if it returns a special value). > > Then I realised that this could also be done with an exception: I could > make up an exception, "Not_In_Active_Window", have Translate_Mouse_Event > raise that exception if the Mouse_Event wasn't in the window, and then > just have a little begin..exception..end block in the code. > > But of these last two approaches, I don't have a feeling for which one is > Good Ada Style(tm). Should exceptions only be used for serious problems? > Using it here would remove a function and chop out some lines of code, but > it's not really much of a savings and the exception block feels like it > would clutter up the event loop at least as much as the if-then. Exceptions should be reserved for exceptional situations. Reading past the end of a file is exceptional because you're expected to test to see if you're at the end of the file before reading. If you then read past the end of file anyway, something exceptional has happened. It sounds as if you could have mouse events outside the proper window at any time, so such an event would not be exceptional. So having a function would probably be a good idea. But if you use the function and still get a mouse event outside the proper window, you should also have an exception to indicate that. -- Jeff Carter "All citizens will be required to change their underwear every half hour. Underwear will be worn on the outside, so we can check." Bananas