On Tue, Mar 01, 2005 at 01:45:56PM -0600, Ken Williams wrote:
> 
> If you allow positive and negative infinity as part of your numerical 
> system, then division by zero moves from "undefined" to 
> "indeterminate", so I suppose one could argue that division by zero 
> should be 'nan' rather than throwing an exception.  Presumably this was 
> some backward-compatibility thing.
> 

        ..which was I guess the original point of my question. Often times
these exceptions happen buried in code where you are e.g. trying to find
the mean value of 0 items. _generally_ the code doesn't occur inside an
eval block, and no useful (to an end user) error is generated if the
application isn't expecting an exception to be thrown.

        I don't disagree with the math issues regarding there not being
a definable value, but in practice the interpreter throwing an exception
has been a much greater problem for me than having a piece of errant data such
as a NaN which will generally cause detectable errors later. Often (always, 
in my experience) they are errors which would be trapped by error detecting
code which isn't expecting exceptions.

        Often this is caused by a module author not expecting an empty list of
arguments, or similar. The author doesn't document a piece of code as capable
of throwing an exception, because they don't think it is. The net result may
be something like a user submitting a web form and getting a blank page in
response.

        Interestingly, bigint sets NaN for 0/0, so it's definitely possible.
I'm going to meditate on this a bit.

        Austin

Reply via email to