[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re[4]: require ignores setglobals()
- From: "Peter Hill" <corwin@...>
- Date: Sat, 8 Feb 2003 02:22:08 +0800
Peter Prade:
> Maybe even the name of "global variables" is a bit misleading now,
> considering that each function may have its own table for them. (Of course
> in the most cases, there will still be only one global table.)
Misleading indeed! In fact 'locals' can now end up being more global than
'globals'!
For example:
local x
function f() x = 1 end
function g() x = y end
function h() return x end
glob = {y = 123}
setglobals(g,glob)
Here 'x' has scope throughout the whole file, while the global 'y' only has
scope inside 'g()'!
Perhaps the name "global" really doesn't apply now. :-(
*cheers*
Peter Hill.