lua-users home
lua-l archive

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

On Wed, Jan 12, 2011 at 3:29 PM, Peter Sommerfeld
<> wrote:
> Ther is no idiomatic way to manage objects in Lua.

this is mine:

----- someclass.lua -----

local setmetatable = setmetatable

module (...)

function new()
	return setmetatable ({}, _M)

function _M:meth1 (arg1,arg2)
	-- use 'self' and args


it does encapsulation, polymorphism and private methods, but not
private vars nor inheritance.  both are easy to add; but  i usually
not bother since about only 1 in 10 of my classes use neither, so i
add only where they actually help.

now i'm tempted to add to the snippets site...