lua-users home
lua-l archive

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


On Sat, Mar 29, 2014 at 12:41 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-03-29 9:35 GMT+02:00 Coda Highland <chighland@gmail.com>:
>> On Sat, Mar 29, 2014 at 12:17 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>> The Lua 5.2 manual says:
>>>
>>>> Equality between function values has changed. Now, a function definition
>>>> may not create a new value; it may reuse some previous value if there is
>>>> no observable difference to the new function.
>>>
>>> This remark says "may". It is surprising that in the simplest possible case,
>>> it does not happen.
>>>
>>> ~~~~
>>> $ lua
>>> Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
>>>> x=function() end; y=function() end
>>>> print(x==y)
>>> false
>>>> print(string.dump(x)==string.dump(y))
>>> true
>>> ~~~~
>>>
>>
>> Is this a quiz question or a legit one? Because I know the answer.
>
> Well, I don't!
>

Answer: Their upvalues differ. The function stored in y has x as an
upvalue; the function stored in x does not.

/s/ Adam