[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible language extension: colon-notation in an expression as shorthand for instance-specific method
- From: "Cimarron Taylor" <cimarron@...>
- Date: Tue, 27 Jan 2009 02:55:37 -0800
Mark,
Metalua (http://metalua.luaforge.net) allows you to write anonymous functions like
function(arg1, arg2, argn) return some_expr end
in this way
|arg1,arg2,argn| some_exp
If can use it then your example becomes
CallbackManager.postMyCallback(| | myInstance:instanceMethod())
Have you considered that?
Regards,
Cimarron Taylor
| We're considering a modification to the version of Lua embedded in our
| game engine that would allow for this construct (which is currently a
| syntax error in Lua):
|
| CallbackManager.postMyCallback(myInstance:instanceMethod)
|
| Under the present language rules, myInstance:instanceMethod is an
| error (as I understand it) because the colon notation is only valid in
| the context of function calls and function declarations, but is not
| valid in the context of specifying a function value. Currently, we can
| accomplish this goal by instead making the statement
| "CallbackManager.postMyCallback(function () myInstance:instanceMethod() end)",
| but that seems to be a great deal more typing than should be necessary.