lua-users home
lua-l archive

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


David Demelier wrote:

At the moment, my preferred solution would be math.type (like io.type,
lpeg.type, etc.):
*   no new global variables
*   no new names
*   no unfamiliar calling conventions
*   if people remove debug functions, they probably won't make an exception
for harmless functions like (sub)type
*   the only reason to remove `math` is if you don't have floats in which
case this function becomes obsolete anyway

Yes, math.type looks absolutely the best solution!

Actually, you don't necessarily remove math[] if you don't have floats.

For my Programmable Brick Lua (pbLua) for LEGO MINDSTORMS NXT based on Lua 5.2 I set the default number type to int, but implemented a single precision float library so that pbLua could have basic trig and log functions that gave single precision float output.

However, handling the float results resulted in a special userdata type which was a general pain in the neck to use.

I am about to build a new version based on Lus 5.3 Work 1 that will (I think) be a huge improvement, and will simplify the handling of mixed numerical types.

I'm looking forward to playing with that!

Ralph