In Lua, I can define a member function like this:
Foo = {}
function Foo:bar()
...
end
I realise this is just syntactic sugar for this:
Foo = {}
foo.bar = function(self)
...
end
Is there a way to write an anonymous function with an implicit self parameter or do I always have to spell out the self parameter on anonymous functions?
The motivation is to create coroutine member functions in a way most analogous to ordinary functions. I can do this:
Foo.bar = coroutine.wrap(function(self) ... end)
Or this:
function Foo:bar() ... end
Foo.bar = coroutine.wrap(Foo.bar)
But is there a way to do a one-line declaration with an implicit self parameter?