More discussion on this here: https://bugs.ecmascript.org/show_bug.cgi?id=309.  
CC Roger Andrews who had argued there that this should be 2- and 3- arguments 
only.  

Personally, I don't see a strong case against allowing hypot to be variadic 
from re-reading that discussion, and do believe that would be a more expected 
behavior for ECMAScript, as for example Waldemar's last comment below points 
out.

Luke

-----Original Message-----
From: Jason Orendorff [mailto:[email protected]] 
Sent: Thursday, August 1, 2013 10:13 AM
To: Allen Wirfs-Brock
Cc: Luke Hoban; es-discuss
Subject: Re: Math.hypot(1)

On Thu, Aug 1, 2013 at 11:46 AM, Allen Wirfs-Brock <[email protected]> 
wrote:
> Waldemar:  Why isn't it variadic?
> Luke:  2 or 3 is the 99% use case.
> Waldemar:  2 or 3 arguments is the 99% use case for max.
> Waldemar:  If it's not variadic and takes only 2 or 3 arguments, 
> you'll get silent mistakes.  If you pass in four arguments, you'll get 
> the hypot of the first three, and the last one will be silently 
> ignored.  That's bad.

Heh! Thanks for the long quote.

It's striking how many good points Waldemar has in this exchange.

> Luke:  Will go back to the experts to explore implementing variadic hypot.

I don't know if I qualify as an expert, but variadic hypot would be no harder 
to implement than what is currently specified (probably easier, honestly), and 
no harder to optimize.

To answer a question posed in that discussion, one way hypot(a, b) is better 
than sqrt(a*a + b*b) is that the latter underflows if the arguments are both 
small, and overflows if either argument is large.

-j



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to