lua-users home
lua-l archive

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


Hi all,

I am a little confused about the following code in Pil:

    i = 32
    local i = 0
    f = load("i = i + 1; print(i)")
    g = function () i = i + 1; print(i) end
    f() --> 33
    g() --> 1

Why does function g() always get local i, not global i? If function
g() wants to
get the global i, how does it do?

Thanks in advance!

Best Regards
Nan Xiao