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,e01fe1b326df26d4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!news.xtra.co.nz!53ab2750!not-for-mail From: "Lurker" Newsgroups: comp.lang.ada References: <79ahr0jozmqb$.10jzllrcjpmsv.dlg@40tude.net> <_pwre.7121$U4.1023104@news.xtra.co.nz> Subject: Re: Division by zero X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: Date: Thu, 30 Jun 2005 13:19:23 +1200 NNTP-Posting-Host: 219.88.164.2 X-Complaints-To: abuse@xtra.co.nz X-Trace: news.xtra.co.nz 1120094153 219.88.164.2 (Thu, 30 Jun 2005 13:15:53 NZST) NNTP-Posting-Date: Thu, 30 Jun 2005 13:15:53 NZST Organization: Xtra Xref: g2news1.google.com comp.lang.ada:11745 Date: 2005-06-30T13:19:23+12:00 List-Id: "Robert A Duff" wrote in message news:wcck6kdguoq.fsf@shell01.TheWorld.com... > "Lurker" writes: > > > "Robert A Duff" wrote in message > > news:wccy88ugorw.fsf@shell01.TheWorld.com... > > > > > 11.6(5) is all about run time effects. If divide by zero were illegal > > > (which means at compile time), then 11.6 would not apply. > > > > Which brings us back to my original question - why is it legal? > > Just to be cleear, we're talking about whether X/Y should be illegal > when Y is a static expression equal to 0. It is illegal if X is also > static, but it is legal if X is nonstatic. Correct. > The reason is that it simplifies the language definition. You don't seem to find any problem with complicating the language definition in the case of static expressions though. And, detecting division by static zero should be a non-issue really. > For division by zero, it is believed to be too restrictive to detect it > at compile time. Why? I mean, you have a static constant which is defined to be equal to zero. Surely compiler knows it's value at compile time (and also the meaning of "/" operator it is used in). > Therefore it's a run-time error. And we trust > compilers to give warnings in cases that can be detected at compile > time. But it would complicate the language definition to describe such > cases, and it would not be clear how "smart" to require the compiler to > be. Sorry, I still don't see how complex it would be. If an expression is static, compiler knows it at compile time, correct? So let's say the rule is that predefined division operation is illegal if the static divisor evaluates to zero. This is already done in the case of static/static expression so it can't be impossible. The only argument in favor of allowing it wold be some legitimate use for it but, except your configuration example, I haven't seen any so far. > Static expressions are special, though: the compiler needs to know the > value of the expression, at last sometimes. We have to make things like > this: > > T'First(1/0) > > illegal, for example, because the type of that expression depends on the > value of 1/0, which doesn't make sense. If I understood your previous comments correctly, 1/0 is already illegal, no matter where it's used. Or have you changed your mind and now say that the use define legality even in static expressions? > > Please excuse all examples of custom "/" definitions. Let's assume > > we are talking about predefined division operation on integers. > > I agree -- everybody is confusing the issue by talking about > user-defined functions that happen to be called "/". > We're talking about predefined division only.