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-28 09:14:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!wn12feed!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: <3DBD7066.1040205@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: <3DBB0508.6010707@acm.org> <8w2v9.20054$T_.485432@iad-read.news.verio.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 28 Oct 2002 17:13:41 GMT NNTP-Posting-Host: 63.184.0.140 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1035825221 63.184.0.140 (Mon, 28 Oct 2002 09:13:41 PST) NNTP-Posting-Date: Mon, 28 Oct 2002 09:13:41 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:30187 Date: 2002-10-28T17:13:41+00:00 List-Id: Dr Nancy's Sweetie wrote: > Jeffrey Carter wrote, in reply to a question about when to use exceptions > and functions for testing error conditions: > >>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. > > > If the function tries to compute a logical address for an invalid > mouse position, a CONSTRAINT_ERROR will be raised because the logical > position will be outside its valid range. > > Is there a good heuristic for "raise your own exception" and "don't > clutter up the exception namespace"? The function returns Boolean: True if the mouse pointer is in the active window; False otherwise. So it should catch the exception and return False. The other subprogram returns the mouse position within the active window, and should only be called if the function mentioned above returns True. But of course people will ignore that rule, and in any case it may be possible for the mouse pointer to move between the 2 calls. If the mouse pointer is outside the active window when this subprogram is called, then it should raise a specific exception to indicate this. Constraint_Error is not very informative in this context. -- Jeff Carter "It's all right, Taggart. Just a man and a horse being hung out there." Blazing Saddles