[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Globals (more ruminations)
- From: Ricardo Ramos Massaro <ricardo.massaro@...>
- Date: Fri, 16 Jul 2010 02:31:32 -0300
On Fri, Jul 16, 2010 at 1:51 AM, Mark Hamburg <mark@grubmah.com> wrote:
> * "global a" as meaning that "a" should be interpreted as "_ENV.a" should be with respect to a specific definition of "_ENV". You may have already meant that, but I don't think you say so above. Which _ENV? My feeling is that it probably should tie to the chunk level _ENV, but I could be persuaded otherwise.
>
> * To preserve existing module construction practice, introducing a new _ENV should eliminate the checks on global assignments.
But what if a module writer *wants* the new check for his modules? In
Roberto's proposal, we can go from this:
# -------
local _ENV = module(...)
global function set_x(new_x)
xx = new_x -- silent error: I meant "x" instead of "xx"
end
# -------
to this:
# -------
local _ENV = module(...)
global x -- declare x and enable checking
global function set_x(new_x)
xx = new_x -- compiler error: attempt to assign to undeclared "xx"
end
# -------
-Ricardo
- References:
- Re: Globals (more ruminations), Jim Jennings
- Re: Globals (more ruminations), Mark Hamburg
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Geoff Leyland
- Re: Globals (more ruminations), Alexander Gladysh
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Juri Munkki
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Patrick Donnelly
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Mark Hamburg