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: g2news2.google.com!news4.google.com!feeder3.cambrium.nl!feeder4.cambrium.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!news-fra1.dfn.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: Thu, 4 Sep 2008 21:27:39 +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> 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 1220552148 2632 141.54.178.228 (4 Sep 2008 18:15:48 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Thu, 4 Sep 2008 18:15:48 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: <48bffbb7$0$74166$dbd49001@news.euronet.nl> Xref: g2news2.google.com comp.lang.ada:7648 Date: 2008-09-04T21:27:39+02:00 List-Id: On Thu, 4 Sep 2008, wrote: > schreef in bericht > news:Pine.LNX.4.64.0809041404570.22581@medsec1.medien.uni-weimar.de... > > >> > 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. > > > You misread what I wrote. A statement such as "if Y/X<000" should > > definitively propagate an exception for X=0, and I never said anything > > otherwise. > > So if I understand you correctly this time, the raising (or not) of an > exception for "if Y/X<000" should in your view depend on the context where > it is used: [...] No, you misread me again. If you had read some earlier posts from me in this thread, what I am trying to express is that "and" should better do what "and then" actually does. That is it, so simple! > I fear that you underestimate the complexities of putting that smartness > in a compiler and you overestimate the abilities of the ordinary > programmers to understand what is going on. 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. ;-) Now really, the whole thing seems to work quite well for "and then". And in quite a few languages other than Ada for "and". > No, I do not think I misread. Your writing was not precise: you wrote > > "if X/=0 and Y/X<100" should go into the else-branch, instead of raising > an exception. > > But in Ada it does not go to the else-branche for X=0. So you are proposing > a language change, and I point out that that would be a vey bad idea. I am not trying to propose to change Ada -- regrettably this would break compatibility too much. But if it where not for compatibility reasons, I would consider to propose that change. > We cannot expect the compiler to be so smart to distinguish exceptions that > are avoidable if the left operand had been evaluated first (as with > conditional boolean operators) from the other exceptions in general. So the > only viable options are: not doing it like this at all (my choice) or > picking the else branche for all exceptions. Strange that the compiler is smart enough to do the right thing if we just write "and then" instead of "and". ;-) > That would make it in invisible exception handler. Bad, bad, bad. And as > noted above, it would also introduce context sensitivity whether > exceptions should be raised or not. Again very bad. Where is the context sensitivity about exceptions when you write "and then"? > And if you do want conditional evaluation, you choose 'and then'. What is > wrong with it? Okay, it is wordy, but the formantics in Ada are very > precise. That is more important than 5 characters saved. I could not care less about the five characters. But the designers of Ada (and the designers of almost any other language out there) have chosen the identifier "and" for a reason. And the reason is that the language "and" actually attempts to mimic the mathematical "and". > Maybe you meant 'and' in your example in a more abstract sense without > providing the precision is demanded by Ada. Unfortunately, you expressed it > as valid Ada. No, I simply complained about a (minor) design flaw of Ada. > > But when "if X/=0 and Y/X<100" propagates an exception for X=0, as, alas, > > done in Ada, something is logically wrong. > > So you do think that it should not raise an exception and go to the > else-branche????? Now what do you want? You contradict yourself. Are you trolling? That quote of mine is a repetition, not a contradiction! > > Dividing something by zero is undefined, not a contradiction. > > That again shows my point that mathematics and computing are two different > beasts. A mathematician will put the pencil done and stop immediately when > asked to do an undefined operation, such as a division by zero. Agreed! But in a lot of mathematical papers, descriptions of algorithms and the like, you actually find expressions like "X/=0 and Y/X<1000". Such an expression does have a well-defined meaning, even for X=0. Nobody would drop his or here pencil. BTW, even the order is an issue -- if you write "Y/X<1000 and X/=0" in a mathematical paper, that would be logically correct, but you could bet on the reviewers asking you to rewrite it to "X/=0 and Y/X<1000". -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------