[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: string.dump the same function is not equal?
- From: Rodrigo Azevedo <rodrigoams@...>
- Date: Thu, 31 Jan 2019 15:53:15 -0300
It should be something like that, in fact
local f1,f2 = string.dump(function(x) x=x+1 return x end,true),
string.dump(function(x) x=x+1 return x end,true)
print(f1 == f2)
returns 'true'. However, from Lua 5.3 manual,
string.dump (function [, strip])
Returns a string containing a binary representation (a binary chunk)
of the given function, so that a later load on this string returns a
copy of the function (but with new upvalues). If strip is a true
value, the binary representation may not include all debug information
about the function, to save space.
What 'may not include all debug information' precisely means?
instead, is there any way to avoid 'all' debug information?
Em qui, 31 de jan de 2019 às 15:42, Жаботинский Евгений
> Coda Highland <firstname.lastname@example.org>:
> On Thu, Jan 31, 2019 at 12:28 PM Rodrigo Azevedo <email@example.com> wrote:
> Anyone could tell me why the code below returns 'false', when I
> expected a 'true' instead. Tested with lua5.2, lua5.3 and
> local f1 = string.dump(function(x) x=x+1 return x end,true)
> local f2 = string.dump(function(x) x=x+1 return x end,true)
> print(f1 == f2)
> Rodrigo Azevedo Moreira da Silva
> Because f2 includes f1 in its upvalues, so they have different contexts.
> /s/ Adam
> Huh? I thought only actually used vars were captured as upvalues. At least from performance / memory usage standpoint that would be common sense.
> My guess is that debug information (at least line numbers) is different, but I didn't check it.
> -- Evgeniy Zhabotinskiy
Rodrigo Azevedo Moreira da Silva