[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: Mark Hamburg <mark@...>
- Date: Thu, 7 Jan 2010 08:52:31 -0800
More on the forthcoming "in env do ... end" construct...
Three somewhat conflicting thoughts:
1. I wonder whether there's a way to make it friendly toward Ruby-style class construction where basically the class gets modified by functions executed inside a block. Something like the following:
local c = makeClass()
in c do
addField "foo"
addField "bar"
function baz( self, yada, yada2 ) end
end
Except that one would want to fold together the class creation and the environment swap via something like:
local c
in c = makeClass() do
addField "foo"
addField "bar"
function baz( self, yada, yada2 ) end
end
Or "cleaner" (but less Lua-like) still:
local c = in makeClass() do
addField "foo"
addField "bar"
function baz( self, yada, yada2 ) end
end
I could also see a case for a metamethod on the value supplied as an environment to be checked as part of the in construct so that the class would not be an environment but could supply one when we needed to use it as such.
2. The above mucks with being able to lint the code since we are actually fine with the global reads of addField and the global set of baz.
3. How much code will get confused by losing the other globals? Will we see a rise in use of package.seeall like constructs? Is something like the PostScript dictionary stack actually more appropriate for non-lexical references?
Mark
- References:
- Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Patrick Donnelly
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Mark Hamburg
- Re: Lua registry, environment, and threads., Patrick Donnelly
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Mark Hamburg