[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: anything wrong by not using "module" ?
- From: Gaspard Bucher <gaspard@...>
- Date: Sat, 26 Mar 2011 16:10:08 +0100
Hi list !
I am wondering if there is anything wrong when defining "classes" in this way (without using module):
======== file lk.Dir ===============================
local lib = {sep = '/', ignore_pattern = '^[.]', type='lk.Dir'}
lib.__index = lib
lk.Dir = lib
setmetatable(lib, {
-- new method
__call = function(table, arg)
local instance = {path = arg}
setmetatable(instance, lib)
return instance
end})
-- private
local function some_helper(self, x, y)
-- ...
end
-- public
function lib:glob(pattern)
-- ...
end
--- etc
======== file lk.Dir ===============================