lua-users home
lua-l archive

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


That's not what luac says:

luac5.3 -l teste_funcs.lua
...
function <teste_funcs.lua:1,1> (3 instructions at 0x556f0d170110)
1 param, 2 slots, 0 upvalues, 1 local, 1 constant, 0 functions
    1    [1]    ADD          0 0 -1    ; - 1
    2    [1]    RETURN       0 2
    3    [1]    RETURN       0 1

function <teste_funcs.lua:2,2> (3 instructions at 0x556f0d170510)
1 param, 2 slots, 0 upvalues, 1 local, 1 constant, 0 functions
    1    [2]    ADD          0 0 -1    ; - 1
    2    [2]    RETURN       0 2
    3    [2]    RETURN       0 1

Em qui, 31 de jan de 2019 às 15:30, Coda Highland
<chighland@gmail.com> escreveu:
>
> On Thu, Jan 31, 2019 at 12:28 PM Rodrigo Azevedo <rodrigoams@gmail.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
> > lua5.4-work2.
> >
> > -----
> > 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)
> > -----
> >
> > Thanks!
> > --
> > Rodrigo Azevedo Moreira da Silva
>
> Because f2 includes f1 in its upvalues, so they have different contexts.
>
> /s/ Adam
>


-- 
Rodrigo Azevedo Moreira da Silva