On Fri, Apr 11, 2014 at 7:23 PM, Peng Zhicheng
<pengzhicheng1986@gmail.com> wrote:
having looked at the `luaV_pow' in lvm.c, I found it is _intentionally_
reported as an error (at least
for current work version) -- since this function translates `pow' into a
serial of `mult' operations.
But this `luaV_pow' is only called when both operands of the OP_POW are
integers. for float point numbers,
`l_mathop(pow)' is used instead.
Lua 5.2 don't have two different internal number representations, thus the
negative exponent is OK.
but, same as Rena, I don't like this behavior either;
one reason is the potential to break existing code, as Rena pointed.
another reason is that I think users should see as little differece between
the number representations as possible,
ans the pow is not concerned as much as the div operator whether it is an
integer or float point operaton.
is the gain (if any) of a special integer pow operation worth the semantic
change?
It's probably faster, but the problem can be addressed by also using
the floating-point version when the RHS operand is negative. It seems
a simple enough change to me.
/s/ Adam