Created
October 19, 2010 10:11
-
-
Save garybernhardt/633959 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = function() | |
y = function() | |
local table = 5 | |
end | |
local old_table = table | |
y() | |
assert(table == old_table and table ~= 5) | |
end | |
x() |
Hmm, works for me
nickmacbookpro:lua nbarendt$ ./bin/lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> x=function()
>> y= function()
>> local table=5
>> end
>> local old_table = table
>> y()
>> table.insert(old_table, 4)
>> assert(table == old_table and table ~=5)
>> end
> x()
>
Odd.. Works for me too, on another machine.. Starting to think I have a bum build on my fedora machine..
bsmith@ubuntu!1029 J:1 M:command
-> lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> x = function()
>> y = function()
>> local table = 5
>> end
>> local old_table = table
>> y()
>> table.insert(old_table, 4)
>> assert(table == old_table and table ~= 5)
>> end
> x()
Also, Nick, try 4 spaces before your snippet to get it to
preserve
Ben, thanks, forgot my Markdown :-(
(or to preview before submitting, :-((
S'cool :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I didn't notice the behavior until I did an operation on the local table with the built in table library.. Seems the table library 'namespace' is what gets stomped on.
Example:
Table library: http://lua-users.org/wiki/TableLibraryTutorial
Gist for you.. http://gist.github.com/634253