lua-users home
lua-l archive

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


Javier Guerra skrev:
On Tuesday 13 June 2006 10:06 am, Andreas Stenius wrote:
2. Even I work on building some kind of OO structure in lua, and
    came across the desire to some new syntactic sugar:

could you show a sample code where this could be useful?


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;
	}
}

would be the same as:

MyTest = class
{
	... the same

	class.private
	{
		bonk = 5;
		phobo = function( ... ) end;
	}
}

Oh, and while I'm at it.. as it is, I'd have to add `self' as the
first argument to every function.. would also be nice to make the
needself arg (in the impl) to be true if a function is declared as

foo = function:( ... )  or something like that... maybe, just thought of it.


I think most of this is feasible, maybe by redesigning the way the function's syntactic sugar work to be more generic for a assignment expr.

//Andreas