comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: OT: A bit  of Sudoku
Date: Thu, 05 Jun 2014 21:00:28 +0200
Date: 2014-06-05T21:00:28+02:00	[thread overview]
Message-ID: <lmqeoe$o76$1@dont-email.me> (raw)
In-Reply-To: <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com>

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


  reply	other threads:[~2014-06-05 19:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 17:49 OT: A bit of Sudoku Mike H
2014-06-05 18:30 ` Adam Beneschan
2014-06-05 19:00   ` J-P. Rosen [this message]
2014-06-05 19:18     ` Jeffrey Carter
2014-06-05 19:43       ` J-P. Rosen
2014-06-05 20:05     ` Mike H
2014-06-05 23:12     ` Robert A Duff
2014-06-05 23:39       ` Adam Beneschan
2014-06-06  7:51         ` Dmitry A. Kazakov
2014-06-06  9:21           ` Georg Bauhaus
2014-06-06 13:38             ` Dmitry A. Kazakov
2014-06-06 15:47           ` Adam Beneschan
2014-06-06 17:09             ` Dmitry A. Kazakov
2014-06-07  6:03             ` J-P. Rosen
2014-06-06 14:13         ` Brad Moore
2014-06-13  0:21     ` Shark8
2014-06-13  6:30       ` J-P. Rosen
2014-06-13 10:10       ` Mike H
2014-06-13 12:37         ` Dmitry A. Kazakov
2014-06-13 15:47         ` Shark8
2014-06-05 20:03   ` Mike H
2014-06-05 20:40     ` Adam Beneschan
2014-06-06  9:10       ` Stefan.Lucks
2014-06-06 10:59         ` Mike H
2014-06-06 16:06         ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox