回复: string.dump(f, true) does not work as expected
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: 回复: string.dump(f, true) does not work as expected
- From: 张睿 <zrui16@...>
- Date: 2015年6月10日 20:16:02 +0800
Oh, I see. Since I tried the code in the interactive interpreter, the place of definition is the same for the two functions (probably something like <stdin:1>).
-------- 原始邮件 --------
发件人: Luiz Henrique de Figueiredo
日期:2015年06月10日 20:02 (GMT+08:00)
收件人: Lua mailing list
主题: Re: string.dump(f, true) does not work as expected
> In Lua 5.3 equal functions are converted to different dumps when
> strip==true.
>
> local function f(x) return x+1 end
> local function g(y) return y+1 end
> print(string.dump(f, true) == string.dump(g, true)) --> false on Lua 5.3,
> true on LuaJIT
>
> If both dumps are load()-ed to exactly the same closures, why these dumps
> are not equal after stripping debug info?
Because the dump keeps the information about where the function was defined.
If you save the bytecodes and list them with luac you'll see
function <?:1,1> (3 instructions at ...)
function <?:2,2> (3 instructions at ...)
which say that f was defined at line 1 and g at line 2.