[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is there any plan to include build-in class support?
- From: Javier Guerra Giraldez <javier@...>
- Date: Wed, 12 Jan 2011 15:38:43 -0500
On Wed, Jan 12, 2011 at 3:29 PM, Peter Sommerfeld
<peter@sommerfeld-stur.at> wrote:
> Ther is no idiomatic way to manage objects in Lua.
this is mine:
----- someclass.lua -----
local setmetatable = setmetatable
module (...)
_M.__index=_M
function new()
return setmetatable ({}, _M)
end
function _M:meth1 (arg1,arg2)
-- use 'self' and args
end
------------------------------
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...
--
Javier