[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: a complex number library
- From: David Manura <dm.lua@...>
- Date: Tue, 4 Jan 2011 21:55:45 -0500
On Tue, Jan 4, 2011 at 3:22 PM, Philippe CASTAGLIOLA
<philippe.castagliola@univ-nantes.fr> wrote:
> I wrote a simple complex number library in pure lua. If you are interested,
> you can go to
> http://philippe.castagliola.free.fr/LUA/complex.html
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)
else
error("bad argument #1 to 'abs' (real or complex number
expected, got %s)",type_(x))
end
end
A similar concern recently came up in [1].
[1] http://lua-users.org/lists/lua-l/2010-12/msg00349.html