We are considering removing some functions from the standard math lib, either because we think few people use them or because they are trivially implemented without the library. The current list is this:
sinh, cosh, tanh: (They are quite specialized, on par with several other functions offered by external libraries, such as lhf’s mathlibx.)
deg, rad, pow: trivially done without the library.
The discussion has been non-stop, and as a programmer who writes a lot of Lua these days I cannot help but egotistically echo my own trivial opinions.
An Important Clarification
Some people have reacted with the mistaken belief that Ierusalimschy proposed removing the sine, cosine, and tangent functions. He is only considering removing the hyperbolic functions. Sine and friends are not going anywhere.
Get Rid of math.pow()
In my opinion that function can go away. Simplicity has always been a core design feature of Lua, and
math.pow() runs contradictory to that simplicity. There is the
^ operator, such that any code
math.pow(x, y) can be written as
x ^ y. The language does not have functions such as
math.add(), so I do not see the need to have a function that does exactly the same thing as an existing arithmetic operator.
But Not the Rest
Personally I believe
math.rad() are useful in terms of readability. Although if they were removed then I would not care that much. Admittedly, they are trivial to implement.
As for the hyperbolic functions, I agree that they are “specialized” but do not see that as a valid reason for their removal. Lua has become popular in the game industry, and functions like the hyperbolic tangent are useful for physics, for example. Again, these can be implemented as needed, but something about their removal fails to meet my personal threshold about the basic mathematical functions the language should provide. Lua’s original math library is ripped right from C89’s
<math.h>. There is discussion about whether or not to include newer math functions from C99, and that partially fuels this discussion about taking the existing functions to the cutting-block.
Personally I think Lua should have a math library that is a wrapper around C89 at the very least. That provides useful, fundamental functions, including the hyperbolic ones. Of course, then there is the whole debate about getting rid of
math.rand()…. I’m in favor of dropping
math.pow() to eliminate the duplicity, but keeping the rest. What do you all think?