[m-rev.] for review: improve standard library error handling

Simon Taylor stayl at cs.mu.OZ.AU
Sat Sep 1 01:11:49 AEST 2001


On 31-Aug-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 30-Aug-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > 
> > 	As discussed on mercury-users a while ago, math__pow(0.0, 0.0)
> > 	should return 1.0. This is also consistent with float__pow.
> > 	See <http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-users/mercury-users.0104/0130.html>.
> 
> There was quite a bit of discussion on that.
> See also http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-users/mercury-users.0107/0006.html.
> 
> I'm not happy with that change, because if I understand correctly it
> violates the LIA 2 standard.  float__pow(0.0, 0) should be one, but
> math__pow(0.0, 0.0) should raise an exception.

I can sort of see why they did this, but these two functions shouldn't
have the same name.

As Richard O'Keefe wrote in the follow-up to the message you quoted:
    "Now, since mathematically x^y for non-integral y is an extension
    of x^n, and this is a far more important defining property than the
    behaviour for any particular x, there is a strong case to be made
    for defining 0^y = 1 also."

Maybe we should have a separate function `math__lia2_pow'.
math__lia2_pow(0.0, 0.0) would throw an exception, and
math__pow(0.0, 0.0) would return 1.0.

It might also be a good idea to redefine `float__pow' in terms of a
version of `math__pow' that doesn't check that the first argument is
positive. It should be more accurate than the repeated multiplication
algorithm we use now.

Simon.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list