[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (work4) now available
- From: Miles Bader <miles@...>
- Date: Tue, 03 Aug 2010 12:21:55 +0900
Jerome Vuarand <jerome.vuarand@gmail.com> writes:
> You can use newindex to perform something similar :
>
> local _M = {}
> local _ENV = setmetatable({},{__index=_ENV, __newindex=_M})
> function foo()
> end
> return _M
cute!
Hmm, even nicer, the boilerplate bits are all at the beginning and end,
so, I could even write my own little "require" analogue that automates
such a pattern for my own modules, using `loadin' to do the loadin'... :]
function my_load_module (name)
local m = {}
local env = setmetatable({},{__index=_ENV, __newindex=m})
loadin (env, name)
return m
end
hmmm
-Miles
--
Monday, n. In Christian countries, the day after the baseball game.
- References:
- Re: [ANN] Lua 5.2.0 (work4) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.0 (work4) now available, Florian Weimer
- Re: [ANN] Lua 5.2.0 (work4) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.2.0 (work4) now available, phlnc8
- Re: [ANN] Lua 5.2.0 (work4) now available, Jim Whitehead II
- Re: [ANN] Lua 5.2.0 (work4) now available, phlnc8
- Re: [ANN] Lua 5.2.0 (work4) now available, Quae Quack
- Re: [ANN] Lua 5.2.0 (work4) now available, GrayFace
- Re: [ANN] Lua 5.2.0 (work4) now available, James Graves
- Re: [ANN] Lua 5.2.0 (work4) now available, Jerome Vuarand