A question about function accessing local and global variables
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: A question about function accessing local and global variables
- From: Nan Xiao <xiaonan830818@...>
- Date: 2015年8月26日 09:53:45 +0800
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