lua-users home
lua-l archive

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

On Tue, Jan 4, 2011 at 3:22 PM, Philippe CASTAGLIOLA
<> wrote:
> I wrote a simple complex number library in pure lua. If you are interested,
> you can go to

Monkey patching standard namespaces, at least if not requested by the
user, is often unnecessary and frowned upon:

  function math.abs(x)
    local z=tonumber(x)
    if z then
      return math_.abs(z)
    elseif is.complex(x) then
      return complex.abs(x)
      error("bad argument #1 to 'abs' (real or complex number
expected, got %s)",type_(x))

A similar concern recently came up in [1].