lua-users home
lua-l archive

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


On Tuesday 13 June 2006 10:23 am, Andreas Stenius wrote:
> class MyTest
> {
> 	class.public
> 	{
> 		foo = function( ... ) end;
> 		bar = function() end;
> 	};
>
> 	class.private
> 	{
> 		bonk = 5;
>
> 		-- my last note for tbl constr.
> 		-- ouch, should work for keyword 'function' too..
> 		function phobo( ... ) end;
> 	}
> }

you can use the same trick as module() does:

local MyTest = { pub = {}, priv = {} }
local prevG = getfenv ()

setfenv (MyTest.pub)

function foo (....) .... end
function bar (....) .... end

setfenv (MyTest.priv)

bonk = 5;
function phobo (...) .... end

setfenv (prevG)



-- 
Javier

Attachment: pgplO5ryEi9xd.pgp
Description: PGP signature