Swap "_ENV" for self though, and suddenly lua can go that extra 10% of the way towards supporting a C++ style implicit self.
Well, maybe I'm overstating things a bit here. I mean, even if you use the pattern
function a.f(_ENV,..)
You still need to explicitly reference self/_ENV anytime you call another member function. So, maybe this is one good reason to prefer defining LUA_ENV to "self", rather than using my patch.
Nested member function calls like these look a lot cleaner if we prefix them with self, rather than _ENV:
function a:f()
self:b()
self:c()
end
On the other hand, it seems easy enough to add an extra little piece of sugar to the parser, so that if we encounter an unprefixed ':' where we expect an _expression_, we replace it with '_ENV : '. i.e., add a case statement like this to lparser:prefixexp:
case ':': {
singlevaraux(ls->fs, ls->envn, v, 1);
return;
}