lua-users home
lua-l archive

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


2014-06-26 8:07 GMT+02:00 Dirk Laurie <dirk.laurie@gmail.com>:
> General comment: with the disappearance of cosh, sinh, tanh from Lua itself,
> considerations come into play that were not pressing for the 5.2
> version of mathx.
> People with programs that used those would hope that putting
>
>     if not math.cosh then require 'mathx' end
>

My way for compatibility is :
      local frexp = require'math'.frexp or require'mathx'.frexp
      local ldexp = require'math'.ldexp or require'mathx'.ldexp

François

> would retain compatibility. That would make it helpful for `mathx` be mentioned
> in the Lua 5.3 manual as an example of a suitable external library.  But not if
> `mathx` while providing the missing functions introduces new incompatinilities.
>
> It used to be simple: `math` is C89, `mathx` is C99, and one could merely
> refer to the respective C documentation. But Lua has gradually moved away
> from blindly following C89, at least where the math library is concerned, and
> the `mathx` module with its README sentence:
>
> ---
> There is no manual: see the summary below and a C99 reference manual, e.g.
>         http://en.wikipedia.org/wiki/C_mathematical_functions
> ---
>
> might slot in better with Lua 5.3 if it could say instead:
>
> ---
> There is no manual: see, in this order, the Lua 5.3 manual, the summary below
> and a C99 reference manual, e.g.
>         http://en.wikipedia.org/wiki/C_mathematical_functions
> ---
>
> Trivial but annoying detail: with gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1) for
> x86_64-linux-gnu, the compiler tells me to add -fPIC to the compiler flags.
> Then it works.
>
> 2014-06-20 15:39 GMT+02:00 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>
>> Perhaps these changes should be done as well:
>>         atan2 -> atan (as in Lua 5.3)
>>         fmin -> min
>>         fmax -> max
>>         log -> accept an optional base
>>
>> Finally, like previous versions of mathx, this one adds functions the
>> existing math library, overwriting the functions already there. This
>> is a problem for abs (which works with integers as well) and log (which
>> accepts an optional base; this one is easy to fix).
>
> As discussed above, requirements should be drop-in. At the very least,
> extra arguments should be errors. Quietly discarding them is confusing.
>
> $ lua53
> Lua 5.3.0 (work3)  Copyright (C) 1994-2014 Lua.org, PUC-Rio
>
>> math.abs(-2)
> 2
>> math.log(1024,2)
> 10.0
>> return math.atan(49,49)/math.pi
> 0.25
>
>> require"mathx"
> table: 0x1e3d960
>
>> return math.abs(-2)
> 2.0
>> return math.log(1024,2)
> 6.9314718055995
>> return math.atan(49,49)/math.pi
> 0.49350478151163
>
> Note that Lua 5.3 now does this:
>
>> math.min('a','b','c')
> a
>
> While I like that, it argues strongly against renaming fmin and fmax.
>