Why are these functions not equal?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Why are these functions not equal?
- From: Dirk Laurie <dirk.laurie@...>
- Date: 2014年3月29日 09:17:49 +0200
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
~~~~