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=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!buffer2.nntp.dca1.giganews.com!border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.stack.nl!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: OT: A bit of Sudoku Date: Thu, 05 Jun 2014 21:00:28 +0200 Organization: A noiseless patient Spider Message-ID: References: <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 5 Jun 2014 19:00:31 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="2b3884a634d8f846e0712b4e3a92507a"; logging-data="24806"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CjUqY+jxOha3iW1JCmXIf" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com> Cancel-Lock: sha1:sZyf3EvgoLXS3COEwxIwTrjUPwY= X-Enigmail-Version: 1.6 X-Original-Bytes: 3080 Xref: number.nntp.dca.giganews.com comp.lang.ada:186744 Date: 2014-06-05T21:00:28+02:00 List-Id: Le 05/06/2014 20:30, Adam Beneschan a écrit : >> The only solution that I can see is to jump straight out of the >> tree. >>> But that seems to lack elegance. The jump is made by raising an >>> exception which has been declared in, and is handled by, the >>> enclosing subprogram. The exception is 'silent' because the >>> handler contains a null statement. >>> >>> I fear that perhaps I am missing something but have no idea >>> what. On the contrary, I think exception are perfectly appropriate for that: they allow to unwind the call stack directly up to the point where you want to catch it by providing a handler. I know that not everybody likes this idea, but to me exceptions are a powerful programming structure, not limited to handling errors. > Without seeing an actual program or any code at all, I can't really > tell, but ... when a caller calls itself recursively, isn't there > either a function result or an OUT parameter that allows the callee > to tell the caller whether it has succeeded? In which case the > caller simply exits, and returns to *its* caller passing back the > correct answer and if necessary a flag indicating that it's > succeeded. I have no idea whether I've identified the problem > correctly, but it's the best I can do without seeing any code. > Anyway, I think that's the general approach to handling backtracking > problems. What you are doing here is just implementing by hand an exception mechanism; that's the only solution when the language does not provide exceptions, but fortunately we have them in Ada.... -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr