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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,99e73f65ea2533b9 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: and then... (a curiosity) Date: Fri, 05 Sep 2008 09:57:29 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <18b41828-bda4-4484-8884-ad62ce1c831d@f36g2000hsa.googlegroups.com> <57qdnfULQ9tzKCHVnZ2dnUVZ_tHinZ2d@comcast.com> <48bd0003$1@news.post.ch> <48bf90bf$0$30032$dbd4d001@news.euronet.nl> <48bffbb7$0$74166$dbd49001@news.euronet.nl> <48c0406c$0$1599$dbd4f001@news.euronet.nl> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1220623050 15885 192.74.137.71 (5 Sep 2008 13:57:30 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 5 Sep 2008 13:57:30 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:hfKn1w439pgUCSI/HOFNqEj+9sM= Xref: g2news1.google.com comp.lang.ada:1945 X-Original-Bytes: 3769 Date: 2008-09-05T09:57:29-04:00 List-Id: stefan-lucks@see-the.signature writes: > On Thu, 4 Sep 2008, wrote: > >> > Very strange that the Ada compiler is able to compile stuff if you write >> > "and then" instead of "and". Following your point, the designers of Ada >> > did overestimate the smartness of compilers. ;-) >> >> My objections are targeted at the thing that you propose (elsewhere called >> 1+2). That beast would either allow bugs to hide, or would require whole >> program analysis and perhaps mind-reading capabilties. > > Firstly, I have been very clear that I didn't "propose" that. > > Secondly, it is easy to implement. What is "it" here? In the below, are you implementing the 1+2 idea, or the 3 idea? Neither one seems right (even ignoring the minor syntax errors)... >... Replace "if A and B then ... else ... > end if" by: > > declare > T_A := A; > begin > if T_A then > return B; -- may raise an exception > end if; > exception > when others => > if B -- may raise an exception > then > raise; -- propagate the exception raised by A > else > return False; > end if; > end; In the above, if B raises an exception the first time, we evaluate B again (and maybe it raises the exception again, or maybe not). Surely that's not what you meant! And the comment "propagate the exception raised by A" is wrong, since the handler doesn't apply to exceptions raised by A. > Hey, do you need mind-reading capabilities for that? Yes, I need to read your mind to know what you meant above. ;-) >...I would consider > this an exercise for Students -- and a really easy one.;-) ;-) > Now, a really ugly issue is that both the evaluation of A and the > evaluation of B might raise an exeption, and we cannot re-raise both > exceptions. If not for other reasons, that suffices not to propagate that. > Well, one could raise a Program_Error in that case, but that is ugly > anyway. But note that even in Ada-as-it-is, it is not defined which of > both exceptions is raised! Sure, that's a little ugly, but in practice it doesn't matter -- the fact that something went wrong is not lost. - Bob