From: Shark8 <OneWingedShark@gmail.com>
Subject: Re: OT: A bit of Sudoku
Date: Thu, 12 Jun 2014 18:21:37 -0600
Date: 2014-06-12T18:21:37-06:00 [thread overview]
Message-ID: <ourmv.598292$hv6.317046@fx17.iad> (raw)
In-Reply-To: <lmqeoe$o76$1@dont-email.me>
On 05-Jun-14 13:00, J-P. Rosen wrote:
> I know that not everybody likes this idea, but to me exceptions are a
> powerful programming structure, not limited to handling errors.
Indeed, you can [ab]use them to get out of otherwise sticky situations,
like the recursion problem when defining your "=" function:
-- Nullable access-string type.
Type LString is Access String;
-- Definition of "=" returns true when both sides are NULL,
-- returns false when only one side is NULL, and behaves as
-- normal string-equality when neither side is NULL.
Function "=" (Left, Right: IN LString) Return Boolean is
Function Is_Equal(Left : LString; Right : String) Return Boolean is
begin
Return Right = Left.All;
exception
When CONSTRAINT_ERROR => Return False;
end Is_Equal;
Begin
Return Is_Equal(Left, Right.All);
Exception
When CONSTRAINT_ERROR =>
begin
-- If this raises CONSTRAINT_ERROR, then both were NULL.
Return Is_Equal(Right,Left.All);
Exception
When CONSTRAINT_ERROR => Return True;
end;
End "=";
next prev parent reply other threads:[~2014-06-13 0:21 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
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 [this message]
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