lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2014-04-07 18:11 GMT+02:00 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:

> I believe those definitions include many other functions not in mathlib
> (and even not in mathx). Should we add them all?

Since the C89 <math.h> is so small, it is easy to say (as is done at present)
"This library is an interface to the standard C math library." That covers
everything currentIy in Lua 5.2 except deg, max, min, pi, rad, random,
randomseed. It even covers having two names, fmod and modf, for the
same function. I would at most add asinh, acosh, atanh for the sake of
symmetry.

Early versions of the Lua documentation simply listed the functions,
only adding extra remarks when the Lua implementation offered something
extra. I would be happy if the documentation for the functions from <math.h>
consisted only of:

===
Everything in the standard C library can be accessed via the following
functions.

    abs acos asin atan atan2 ceil cos cosh exp floor fmod frexp huge
    ldexp log modf pow sin sinh sqrt tan tanh

(a) `abs` is `fabs` in C.
(b) `huge` is `HUGE_VAL` in C.
(c) To get `log10(x)`, use `log(x,10)`. Any positive number `base`
may be given as second argument to `log`.
===

BTW the point made by "Coroutines", that the math library checks
that its arguments are numbers, should not be missed.