lua-users home
lua-l archive

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


Hello All,

Having start learning Lua for few days, I'm stuck ( or let say don't know
how to start ) with this problem :

Here is what is working the way I want ( all in Lua ) :

--first :

x  = getVar( "X" )

--getVar() is a C function I made which read
-- some prefs data in my business environment.

--then :

T = {}
local mT = {
    __index = function( t, k)
    return getVar( k )
end,
    __newindex = function(t,k,v)
    error("T is read-only", 2)
end
}
setmetatable( T, mT)

x = T[ "x"]
------------------------

What I would like to do is to write these few lines in C.
The table T should be a global var ( no library, modules )

Any pointers, link or pseudo-code to start would be very much appreciated

Regards,
Thierry