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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: border2.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx17.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:32.0) Gecko/20100101 Thunderbird/32.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: OT: A bit of Sudoku References: <5365d3f0-43cc-47ef-989c-d47992c84c9f@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Fri, 13 Jun 2014 00:21:40 UTC Organization: TeraNews.com Date: Thu, 12 Jun 2014 18:21:37 -0600 X-Received-Bytes: 1976 X-Received-Body-CRC: 1045063169 Xref: number.nntp.dca.giganews.com comp.lang.ada:186878 Date: 2014-06-12T18:21:37-06:00 List-Id: 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 "=";