On Jul 24, 2013, at 1:09 PM, Leo Romanoff <email@example.com> wrote:
The only drawback I would expect is that I need an additional table access every time when I need to access a Lua object. Therefore I'm not sure about the "efficient" part of my requirement.
The trouble with this approach is the contract between Lua and C regarding memory management becomes very complex, and any issues with any C code inevitably lead to nasty hard to find crashes in Lua. Python uses something akin to your request, and suffers badly as a result (the API is a horror to work with imho). The Lua stack model isn't perfect, but it provides a good level of protection while enabling pretty much any user scenario, though at a modest execution cost.