lua-users home
lua-l archive

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

The Vector3 example in the original post can certainly be done using user data, sorry for the misleading remark. But, I don't see how one can design a userdata or table in such a way that standard math.abs would work on it, for instance. On you LBC library, can one say something like this 

print (math.abs (bc) ) 

without any modifications to abs? 

 -----Original Message-----
From: 	Luiz Henrique de Figueiredo [] 
Sent:	Monday, June 16, 2003 9:54 AM
Subject:	RE: Passing values by reference?

>Unfortunately one can't emulate numbers with userdata in Lua. This makes the original poster's example impossible to do with no modifications to Lua core. For whatever reasons (minimalism, simplicity and performance I would think) one can only do math on two values of the same type in Lua and type coercion is not supported.

Not true. Check out my arbitrary precision libraries (lbc and lmapm) at
You can freely mix arbitrary-precision numbers with ordinary Lua numbers
in the same expression.