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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.57.84 with SMTP id g20mr90790igq.8.1402011588074; Thu, 05 Jun 2014 16:39:48 -0700 (PDT) X-Received: by 10.50.120.1 with SMTP id ky1mr416igb.7.1402011587969; Thu, 05 Jun 2014 16:39:47 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!c1no23665219igq.0!news-out.google.com!qf4ni19593igc.0!nntp.google.com!c1no23665210igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 5 Jun 2014 16:39:47 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: OT: A bit of Sudoku From: Adam Beneschan Injection-Date: Thu, 05 Jun 2014 23:39:47 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:20156 Date: 2014-06-05T16:39:47-07:00 List-Id: On Thursday, June 5, 2014 4:12:55 PM UTC-7, Robert A Duff wrote: > In any case, if you need to jump out of many layers of (recursive?) > calls, an exception might well be the best way. Checking error > codes at each level might be verbose and error prone. I don't like it. But if you do something like this, I'd suggest that this = use be limited to an exception that you declare inside a subprogram, so tha= t you raise and handle it only inside that subprogram or nested subprograms= . Otherwise, someone could look at a subprogram that is called in between,= and never guess that the subprogram might not complete normally (A calls B= , B calls C, C raises an exception that gets passed over B's head back to A= ; a programmer trying to read B might not suspect that B may not complete i= n a non-error situation.) In other words, keep such usages as localized as= possible. Another thing to keep in mind is that exceptions cause overhead. I've seen= implementations that have to do some stuff any time a subprogram or a bloc= k with an exception handler is entered. I've seen other implementations th= at, in order to eliminate this overhead in "normal" (non-exception) cases, = perform table lookups on each address in the stack until it finds a handler= ; this is a relatively expensive operation that those implementations have = decided is justified because exceptions aren't supposed to happen in "norma= l" cases. Whether this overhead is less than the expense of going through = a number of returns, I don't know--I'm sure it depends on various factors. = But efficiency should not be a reason to use exceptions instead of straigh= t returns, because it may well make things slower. -- Adam