comp.lang.ada
 help / color / mirror / Atom feed
From: "Lurker" <nowhere@nothing.com>
Subject: Re: Division by zero
Date: Thu, 30 Jun 2005 13:19:23 +1200
Date: 2005-06-30T13:19:23+12:00	[thread overview]
Message-ID: <dJHwe.11417$U4.1452456@news.xtra.co.nz> (raw)
In-Reply-To: wcck6kdguoq.fsf@shell01.TheWorld.com

"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
news:wcck6kdguoq.fsf@shell01.TheWorld.com...
> "Lurker" <nowhere@nothing.com> writes:
>
> > "Robert A Duff" <bobduff@shell01.TheWorld.com> 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.





  parent reply	other threads:[~2005-06-30  1:19 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-11 21:03 Division by zero Lurker
2005-06-12  2:00 ` David C. Hoos, Sr.
2005-06-12  3:04   ` Lurker
2005-06-12  8:39     ` Dmitry A. Kazakov
2005-06-12  9:43       ` Lurker
2005-06-12 10:36         ` Marius Amado Alves
2005-06-12 11:53         ` Dmitry A. Kazakov
2005-06-13  8:03         ` Ole-Hjalmar Kristensen
2005-06-12 13:10       ` Robert A Duff
2005-06-12 16:55         ` Jeffrey Carter
2005-06-13  3:22           ` Keith Thompson
2005-06-14  2:14             ` Jeffrey Carter
2005-06-13  8:47           ` Lurker
2005-06-14  2:19             ` Jeffrey Carter
2005-06-14  8:35               ` Keith Thompson
2005-06-13 12:19           ` Robert A Duff
2005-06-14  2:31             ` Jeffrey Carter
2005-06-14  8:21             ` Lurker
2005-06-14 20:22               ` Randy Brukardt
2005-06-28 21:22               ` Robert A Duff
2005-06-29  5:50                 ` Lurker
2005-06-29 13:27                   ` Robert A Duff
2005-06-29 13:54                     ` Dmitry A. Kazakov
2005-06-29 16:03                       ` Robert A Duff
2005-06-30  1:19                     ` Lurker [this message]
2005-06-30 11:16                       ` Stuart Palin
2005-06-29 13:50                   ` Dmitry A. Kazakov
2005-06-29 16:07                     ` Robert A Duff
2005-06-30  8:27                       ` Dmitry A. Kazakov
2005-06-29  9:20                 ` Lurker
2005-06-29  9:49                   ` Christoph Grein
2005-06-29 10:40                     ` Lurker
2005-06-29 11:04                       ` Jeff Creem
2005-06-29 12:28                         ` Martin Dowie
2005-06-29 13:40                   ` Robert A Duff
     [not found]     ` <5sana1pm436l6vboifijqblu0irf84afkr@4ax.com>
2005-06-12 17:38       ` Simon Wright
2005-06-12 12:21 ` Robert A Duff
2005-06-12 22:53 ` Georg Bauhaus
2005-06-13  8:34   ` Lurker
2005-06-13  8:54     ` Marius Amado Alves
2005-06-13 17:59       ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox