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!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Division by zero Date: 29 Jun 2005 09:27:01 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <79ahr0jozmqb$.10jzllrcjpmsv.dlg@40tude.net> <_pwre.7121$U4.1023104@news.xtra.co.nz> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1120051621 6713 192.74.137.71 (29 Jun 2005 13:27:01 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 29 Jun 2005 13:27:01 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:11731 Date: 2005-06-29T09:27:01-04:00 List-Id: "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. The reason is that it simplifies the language definition. For any particular "kind" of error, the language design style used for Ada is to choose one of: - always detect this error at compile time - always detect this error at run time For division by zero, it is believed to be too restrictive to detect it at compile time. 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. 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. (In the above, I'm ignoring the rare cases of errors that are not detected at all, or are detected at link time, etc.) > 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. > Why would division by zero be allowed? (If you want to redefine > your operations, then all bets are off of course, but what about > the default ones?) - Bob