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: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!news2.euro.net!postnews2.euro.net!news.euronet.nl!not-for-mail From: "Karel Th�nissen" Newsgroups: comp.lang.ada References: <18b41828-bda4-4484-8884-ad62ce1c831d@f36g2000hsa.googlegroups.com> <57qdnfULQ9tzKCHVnZ2dnUVZ_tHinZ2d@comcast.com> <48bd0003$1@news.post.ch> Subject: Re: and then... (a curiosity) Date: Thu, 4 Sep 2008 09:39:38 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original Message-ID: <48bf90bf$0$30032$dbd4d001@news.euronet.nl> Organization: EuroNet Internet NNTP-Posting-Date: 04 Sep 2008 07:39:43 GMT NNTP-Posting-Host: ht-c-98a0.mxs.adsl.euronet.nl X-Trace: 1220513983 dr5.euro.net 30032 62.234.184.160:1279 X-Complaints-To: abuse@euronet.nl Xref: g2news2.google.com comp.lang.ada:7635 Date: 2008-09-04T07:39:43+00:00 List-Id: schreef in bericht news:Pine.LNX.4.64.0809040835270.21815@medsec1.medien.uni-weimar.de... >> What is the "logic level"? >> I you mean "abstract Boolean logic, like in college", then there is no >> such thing as Constraint_Error, nor side effects. So of course it >> gives you a bad understanding of programming languages. Exactly. Programming is not mathematics and the resemblance is so close that it is dangerous. > Actually, there is Constraint_Erorr, though under a different name. ;-) > If your Boolean function is allowed to raise an exception, this is the > same as returning "undefined" in three-valued logic, as I pointed out in > another posting in this mail. > This is the point I had been trying to make in all my postings to this > thread: "False and Undefined" is False, not Undefined! That depends on the type of ternary logic that you consider. If the third value stands for 'unknown' then: false and unknown => false However, if the third value is used for contradiction, then: false and contradiction => contradiction That is what Ada does with exceptions. > Thus, "if X/=0 and Y/X<100" should go into the else-branch, instead of > raising an exception. > The shortcut version "if X/=0 and then Y/X<100" does exactly the right > thing. That would be a very bad idea. With that in place, an exception raised by a simple programming error, /any/ programming error, would give control to the else-branch. Nice if the exception is the one that you know that could happen, otherwise disasterous. It has become a exception handler in disguise, but one that confuses falsity with exceptions. If this is what you want you should invent a 3-branched selection statement. I agree with other posters that the choice between conditional and unconditional AND should be explicit and documented. One may not like the syntax chosen in Ada, but it is the only sensible design. Groeten, Karel