lua-users home
lua-l archive

Re: _ENV vs _G

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


2014年08月11日 21:13 GMT+02:00 Mason Mackaman <masondeanm@aol.com>:
> Okay, I’ve figured out the relationship between _G and _ENV, _ENV=_G.
> The reason things were confusing me before is I had forgotten that _G is
> really _ENV._G, so that clears that up. But now the other part of my
> question is even bigger, What the hell is the point of _G?
Good question, since if you have clobbered _ENV then _ENV._G is no
longer accessible either.
But the test
if tbl==tbl._G then
 print "I'll bet `tbl` is the original global environment"
end
is likely to be correct unless you have been clobbering _G.

AltStyle によって変換されたページ (->オリジナル) /