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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news-lei1.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: and then... (a curiosity) Date: Fri, 5 Sep 2008 09:25:17 +0200 Organization: Bauhaus-Universitaet Weimar 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> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tigger.scc.uni-weimar.de 1220595207 3140 141.54.178.228 (5 Sep 2008 06:13:27 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Fri, 5 Sep 2008 06:13:27 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: <48c0406c$0$1599$dbd4f001@news.euronet.nl> Xref: g2news1.google.com comp.lang.ada:1933 Date: 2008-09-05T09:25:17+02:00 List-Id: 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. 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; Hey, do you need mind-reading capabilities for that? 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! > > is that the language "and" actually attempts to mimic the mathematical > > "and". > > Yes, I agree and that is very unfortunate. But while we are at it. The > 'designers' of logic made the same mistake: they have chosen an > interpretation that difference from the word "and" in English. OK, here we disagree. They wanted the "and", because they wanted to mimic the mathematical and -- as much as the designers of most other languages. As much as integer addition mimics the addition over the integers ... > Quite possible. Perhaps a logic with: > > false and undefined <=> undefined and false <=> false > > If that is the definition, then that would be possible. But this is not the > nave definition from Boolean algebra. This definition must be learned, but > then you could equally well learn both well-defined definitions as from Ada. > > But you may still prefer above definition from a three-valued logic. I > agree, the logic is well-defined and mathemtically elegant. However, it is > an engineering disaster. We write millions of lines of code and we must deal > with violations, exceptions, and validations errors. The better it would be to focus on actual violations. Instead of hunting an exception raised in fragments such as "if X/=0 and Y/X