lua-users home
lua-l archive

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


I'm trying to use the pow function, but it does not work. Even though it is not mentioned in the manual, it seems to be supported in lmathlib.c:

static int math_pow (lua_State *L) {
  lua_pushnumber(L, pow(luaL_check_number(L, 1), luaL_check_number(L, 2)));
  return 1;
}

While most of the mathematical functions are defined in the luaL_reg mathlib structure in lmathlib.c, it seems pow is defined differently in lua_mathlibopen:

  lua_pushcfunction(L, math_pow);
  lua_settagmethod(L, LUA_TNUMBER, "pow");

I'm new to lua, but I would guess this code is supposed to demo how to define pow as a function in a different manner than using the luaL_reg mathlib structure.

The problem of course is that "pow" is not visible to lua.

Is pow supposed to be supported, and if so can I safely assume that it is a bug for now (and add it the same way the other functions are being used)?

Thanks,

Marius