local mt = {} function mt:__call(instance) instance = instance or {} assert(type(instance) == 'table') local ci = setmetatable({i = instance, inited = false, obj = false}, {__index = self, __newindex = function()assert(false)end}) return ci end -- create a new component type. the arguments are interpreted as a list of -- dependences. each dependency is expressed as an array. the first value is -- the component type. the optional second value is the default properties local function component(...) local c = {} c.component_type = c c.deps = {...} for i, dep in ipairs(c.deps) do assert(#dep ~= 0) end c.init = function() end return setmetatable(c, mt) end return component